{
  "openapi": "3.0.4",
  "info": {
    "title": "Sodium API",
    "description": "A comprehensive API for Sodium Practice Management",
    "version": "v1"
  },
  "paths": {
    "/tenants/{tenant}/agent-authorisations": {
      "get": {
        "tags": [
          "Agent Authorisations"
        ],
        "summary": "List Clients Needing Authorisations",
        "description": "Lists the clients whose active or proposed services require one of the requested HMRC authorisation types, one row per client, with an entry for each type that client needs. A type a client does not need simply has no entry. Filtering by status selects which clients appear, not which of their authorisations are returned, so a row always shows everything the client needs rather than only the part that matched. Filtering by HMRC verification result works the same way, and reads a client that cannot be checked as missing details whatever result is stored against it.\n\nRequires: ViewAll on Clients.",
        "operationId": "getAgentAuthorisationSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "authorisationTypes",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/AgentAuthorisationType"
              }
            },
            "x-order": 400
          },
          {
            "name": "statuses",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/AgentAuthorisationStatus"
              }
            },
            "x-order": 400
          },
          {
            "name": "verificationResults",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/HmrcVerificationResult"
              }
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "type": "string",
              "example": "Name"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentAuthorisationSummaryClientDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/agent-authorisations/counts": {
      "get": {
        "tags": [
          "Agent Authorisations"
        ],
        "summary": "Count Authorisations By State",
        "description": "Practice-wide tallies of required agent authorisations: how many sit in each status and, for the Making Tax Digital types, what HMRC last said about each. Counted separately from the paged list, which cannot produce totals, and deliberately unfiltered by status.\n\nRequires: ViewAll on Clients.",
        "operationId": "getAgentAuthorisationCounts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "authorisationTypes",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/AgentAuthorisationType"
              }
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentAuthorisationCountsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/agent-authorisations/hmrc-client-list/preview": {
      "post": {
        "tags": [
          "Agent Authorisations"
        ],
        "summary": "Preview HMRC Client List",
        "description": "Reads an HMRC client list CSV (Self Assessment, Corporation Tax, PAYE for Employers or CIS, told apart by its headers) and matches each row to a client: on the UTR or PAYE reference, then company number, then the practice's own reference, then name. Saves nothing. Also lists the clients recorded as Granted for that type that the list does not show.\n\nRequires: ViewAll on Clients and Update on Clients.",
        "operationId": "previewHmrcClientList",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewHmrcClientListRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcClientListPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/agent-authorisations/hmrc-client-list/apply": {
      "post": {
        "tags": [
          "Agent Authorisations"
        ],
        "summary": "Apply HMRC Client List",
        "description": "Saves the statuses confirmed after a preview: Granted for clients on the list (closing any letter request still awaiting its code), Not Requested for granted clients the list does not show. Clients already at the confirmed status are left alone.\n\nRequires: ViewAll on Clients and Update on Clients.",
        "operationId": "applyHmrcClientList",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyHmrcClientListRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcClientListApplyResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/agent-authorisations/bulk-requests/check": {
      "post": {
        "tags": [
          "Agent Authorisations"
        ],
        "summary": "Check Bulk HMRC Request",
        "description": "Checks which clients one letter-based HMRC authorisation (Self Assessment, Corporation Tax, PAYE or CIS) can be requested for straight away, and lists what the rest are missing: a UTR, a postcode, the employer references, or an email address for the code entry link. With no client codes it checks every client whose services need the authorisation and who has not had it requested. Sends nothing.\n\nRequires: Update on Clients.",
        "operationId": "checkHmrcBulkRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckHmrcBulkRequestDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/HmrcBulkRequestClientCheckDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/agent-authorisations/bulk-requests": {
      "post": {
        "tags": [
          "Agent Authorisations"
        ],
        "summary": "Start Bulk HMRC Request",
        "description": "Requests one letter-based HMRC authorisation for many clients. Saves any UTR, PAYE or Accounts Office reference given for a client, leaves out the clients still missing details (returned with the reason), and queues the rest: each is sent to HMRC in the background exactly as a single request is, with the same status, emails and chasing. 202 Accepted with a Location to poll for progress; 200 OK when no client could be sent, with the reasons.\n\nRequires: Update on Clients.",
        "operationId": "startHmrcBulkRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartHmrcBulkRequestDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcBulkRequestStartedDto"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcBulkRequestStartedDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/agent-authorisations/bulk-requests/{code}": {
      "get": {
        "tags": [
          "Agent Authorisations"
        ],
        "summary": "Get Bulk HMRC Request",
        "description": "A bulk HMRC request's progress: how many requests reached HMRC, which failed and why, and how many are still waiting to be sent.\n\nRequires: ViewAll on Clients.",
        "operationId": "getHmrcBulkRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcBulkRequestDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/ai/settings": {
      "get": {
        "tags": [
          "AI"
        ],
        "summary": "Get AI Settings",
        "description": "Returns the AI settings for the specified tenant\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetAiSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "AI"
        ],
        "summary": "Update AI Settings",
        "description": "Updates the AI settings for the specified tenant\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateAiSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAiSettingsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/ai/models": {
      "get": {
        "tags": [
          "AI"
        ],
        "summary": "List AI Models",
        "description": "Returns the models a practice can choose in its AI settings, each with the name to show and the provider\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "ListAiModels",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AiModelDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/ai/generate": {
      "post": {
        "tags": [
          "AI"
        ],
        "summary": "Generate Content",
        "description": "Generates content using AI based on the activity type and key provided. Supports various content types like service descriptions, proposals, workflows, pricing factors, etc.\n\nOpen to any signed-in user of the tenant: Checked in AiGenerationUseCase by activity: the caller needs Create or Update on what the content is drafted for",
        "operationId": "GenerateAiContent",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiGenerationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenRouterResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "500": {
            "description": "Internal Server Error"
          }
        },
        "x-no-permission-reason": "Checked in AiGenerationUseCase by activity: the caller needs Create or Update on what the content is drafted for"
      }
    },
    "/tenants/{tenant}/ai/usage/summary": {
      "get": {
        "tags": [
          "AI"
        ],
        "summary": "Get Usage Summary",
        "description": "Retrieves AI token usage summary for a date range\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetAiUsageSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "startDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "x-order": 100
          },
          {
            "name": "endDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "x-order": 101
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiUsageSummaryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/announcements/current": {
      "get": {
        "tags": [
          "Announcements"
        ],
        "summary": "Get Current Announcement",
        "description": "Returns the platform announcement banner to show in-app right now, or 204 when none is active.\n\nOpen to any signed-in user of the tenant: The platform-wide announcement banner, shown to every signed-in user",
        "operationId": "GetCurrentAnnouncement",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrentAnnouncementDto"
                }
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The platform-wide announcement banner, shown to every signed-in user"
      }
    },
    "/account/keys": {
      "get": {
        "tags": [
          "API Keys"
        ],
        "summary": "List all API keys for the current user",
        "description": "Returns all API keys associated with the currently authenticated user. Not available to API key callers.",
        "operationId": "ListApiKeys",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApiKeyDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "API Keys"
        ],
        "summary": "Create a new API key",
        "description": "Creates a new API key for the currently authenticated user. Not available to API key callers.",
        "operationId": "CreateApiKey",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/account/keys/{key}": {
      "put": {
        "tags": [
          "API Keys"
        ],
        "summary": "Update an API key's name and scope",
        "description": "Updates an API key's name and tenant/role scope (full replacement — omit the scope fields to make the key unscoped). Use the Key (Guid) as the identifier; the key value itself never changes. Not available to API key callers.",
        "operationId": "UpdateApiKey",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateApiKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "API Keys"
        ],
        "summary": "Delete an API key",
        "description": "Deletes an API key for the currently authenticated user. Use the Key (Guid) as the identifier. Not available to API key callers.",
        "operationId": "DeleteApiKey",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/tenants/{tenant}/broadcasts": {
      "get": {
        "tags": [
          "Broadcasts"
        ],
        "summary": "List Broadcasts",
        "description": "Returns a paged list of the practice's bulk emails and bulk texts together, newest first. Filter by status and by channel (Email or Text). Open a row on its channel's own routes by its code.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "ListBroadcasts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/BroadcastSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by status (Draft, Queued, Sending, Completed, Failed, Cancelled, Scheduled, Paused)",
            "schema": {
              "enum": [
                "Draft",
                "Queued",
                "Sending",
                "Completed",
                "Failed",
                "Cancelled",
                "Scheduled",
                "Paused"
              ],
              "type": "string",
              "example": "Draft"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "description": "Filter by kind (Email, Text)",
            "schema": {
              "enum": [
                "Email",
                "Text"
              ],
              "type": "string",
              "example": "Text"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BroadcastListItemDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/services/{code}": {
      "get": {
        "tags": [
          "Budgets"
        ],
        "summary": "Get Service Budget",
        "description": "The service's standard budget: its period, hours mode and figure, the typical step total, and (with Fee Budgets ViewAll while fee budgets are on) the fee and the service's charge-out rate.\n\nRequires: ViewAll on JobBudgets.",
        "operationId": "GetServiceBudget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceBudgetDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "JobBudgets",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Budgets"
        ],
        "summary": "Update Service Budget",
        "description": "Sets the service's budget period and standard hours. The fee is not part of this route. Turning the hours off while there is no fee removes the standard.\n\nRequires: Update on JobBudgets.",
        "operationId": "UpdateServiceBudget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateServiceBudgetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "JobBudgets",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/services/{code}/fee": {
      "put": {
        "tags": [
          "Budgets"
        ],
        "summary": "Update Service Fee Budget",
        "description": "Sets the service's standard fee budget per period: each client's price, a figure, a figure per stage, or none. 400 while the practice has fee budgets switched off.\n\nRequires: Update on FeeBudgets.",
        "operationId": "UpdateServiceFeeBudget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateServiceFeeBudgetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "FeeBudgets",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/services/{code}/overrides": {
      "get": {
        "tags": [
          "Budgets"
        ],
        "summary": "List Service Budget Overrides",
        "description": "Every client service on this service with a figure of its own, by client name: which lines, the figure and the standard beside it, for the client's current period. Fee lines need Fee Budgets ViewAll.\n\nRequires: ViewAll on JobBudgets.",
        "operationId": "ListServiceBudgetOverrides",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ServiceBudgetOverrideDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "JobBudgets",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/services/{code}/overrides/reset": {
      "post": {
        "tags": [
          "Budgets"
        ],
        "summary": "Reset Client Budget Overrides",
        "description": "Clears every own hours figure on the given client services of this service. Their modes and percentages stay. Returns how many had one.\n\nRequires: Update on JobBudgets.",
        "operationId": "ResetClientBudgetOverrides",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResetBudgetOverridesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResetBudgetOverridesResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "JobBudgets",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/services/{code}/fee/overrides/reset": {
      "post": {
        "tags": [
          "Budgets"
        ],
        "summary": "Reset Client Fee Budget Overrides",
        "description": "Clears every own fee figure on the given client services of this service. Their modes and percentages stay. Returns how many had one. 400 while the practice has fee budgets switched off.\n\nRequires: Update on FeeBudgets.",
        "operationId": "ResetClientFeeBudgetOverrides",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResetBudgetOverridesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResetBudgetOverridesResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "FeeBudgets",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/clients/{client}/services/{code}": {
      "get": {
        "tags": [
          "Budgets"
        ],
        "summary": "Get Client Service Budget",
        "description": "The client service's budget for its current period: how hours and fee relate to the standard, each line's standard, own and effective figure, and the period's step estimates.\n\nRequires: ViewAll on JobBudgets.",
        "operationId": "GetClientServiceBudget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientServiceBudgetDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "JobBudgets",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Budgets"
        ],
        "summary": "Update Client Service Budget",
        "description": "Sets how this client's hours relate to the standard (follow it, adjust it by a percentage, or no budget) and its own figures, in minutes. Lines left out follow the standard.\n\nRequires: Update on JobBudgets.",
        "operationId": "UpdateClientServiceBudget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientServiceBudgetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "JobBudgets",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/clients/{client}/services/{code}/fee": {
      "put": {
        "tags": [
          "Budgets"
        ],
        "summary": "Update Client Service Fee Budget",
        "description": "The same as the client service budget route, for the fee. 400 while the practice has fee budgets switched off.\n\nRequires: Update on FeeBudgets.",
        "operationId": "UpdateClientServiceFeeBudget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientServiceBudgetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "FeeBudgets",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/clients/{client}/services/{code}/progress": {
      "get": {
        "tags": [
          "Budgets"
        ],
        "summary": "Get Client Service Budget Progress",
        "description": "The current period and the ones before it (cycles in all, newest first), each with its budget, the time logged and its status. With asOf, only the period containing that date. Empty while budgets are off.\n\nRequires: ViewAll on JobBudgets.",
        "operationId": "GetClientServiceBudgetProgress",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "asOf",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "cycles",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 7
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BudgetCycleProgressDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "JobBudgets",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/clients/{client}/services/{code}/periods/{start}/breakdown": {
      "get": {
        "tags": [
          "Budgets"
        ],
        "summary": "Get Client Service Budget Breakdown",
        "description": "One period of the job, named by its start date (cycleStart): the period as the progress route gives it, its time by task (tasks by start date, then time logged straight to the service) and by team member (most minutes first, with the average rate). Value of time and the rate need Fee Budgets ViewAll; a caller restricted to their own time sees only their own minutes. 404 when the date does not start one of the service's periods; forbidden while budgets are off.\n\nRequires: ViewAll on JobBudgets.",
        "operationId": "GetClientServiceBudgetBreakdown",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "start",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetBreakdownDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "JobBudgets",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/clients/{client}": {
      "get": {
        "tags": [
          "Budgets"
        ],
        "summary": "Get Client Budget Progress",
        "description": "The current period of every service of the client that has a budget. Totals only. Empty while budgets are off.\n\nRequires: ViewAll on JobBudgets.",
        "operationId": "GetClientBudgetProgress",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BudgetCycleProgressDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "JobBudgets",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/budgets": {
      "get": {
        "tags": [
          "Budgets"
        ],
        "summary": "Get Budgets Report",
        "description": "One row per client service and period with a budget: the running period (period=Current), the one before (Previous), or every period overlapping from..to (Window). Filter by serviceCode, clientCode and status (matching either the hours or the fee status). Sorted by how much of the budget is used, worst first. Fee columns need Fee Budgets ViewAll; hidden from users restricted to their own time, and from everyone while budgets are off.\n\nRequires: ViewAll on Reports and ViewAll on JobBudgets.",
        "operationId": "GetBudgetsReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/BudgetStatus"
            },
            "x-order": 200
          },
          {
            "name": "clientCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "byStage",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "period",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/BudgetReportPeriod"
            },
            "x-order": 400
          },
          {
            "name": "serviceCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetCycleProgressDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          },
          {
            "entity": "JobBudgets",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/budgets/csv": {
      "get": {
        "tags": [
          "Budgets"
        ],
        "summary": "Export Budgets Report",
        "description": "Every row of the Budgets report as CSV, hours to one decimal place and money to two. Fee columns only with Fee Budgets ViewAll. Forbidden while budgets are off.\n\nRequires: Export on Reports and ViewAll on JobBudgets.",
        "operationId": "GetBudgetsReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/BudgetStatus"
            },
            "x-order": 200
          },
          {
            "name": "clientCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "byStage",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "period",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/BudgetReportPeriod"
            },
            "x-order": 400
          },
          {
            "name": "serviceCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          },
          {
            "entity": "JobBudgets",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/tasks/{code}": {
      "get": {
        "tags": [
          "Budgets"
        ],
        "summary": "Get Task Budget",
        "description": "The budget period the task belongs to, with the time logged on the task itself. The period is null when the task has no service, the service has no budget, or budgets are off.\n\nRequires: ViewAll on Tasks and ViewAll on JobBudgets.",
        "operationId": "GetTaskBudget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBudgetDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          },
          {
            "entity": "JobBudgets",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/calendar-feed": {
      "get": {
        "tags": [
          "Calendar Feed"
        ],
        "summary": "Get Calendar Feed",
        "description": "Gets the current user's iCalendar subscription URL, creating it on first request.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetCalendarFeed",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarFeedDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/calendar-feed/reset": {
      "post": {
        "tags": [
          "Calendar Feed"
        ],
        "summary": "Reset Calendar Feed",
        "description": "Issues a new secret URL for the current user's feed. Existing subscriptions to the old URL stop working immediately.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ResetCalendarFeed",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarFeedDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/calendar-feed/{token}.ics": {
      "get": {
        "tags": [
          "Calendar Feed"
        ],
        "summary": "Get Calendar Feed File",
        "description": "Returns the iCalendar document for a feed token. Called anonymously by calendar clients.",
        "operationId": "GetCalendarFeedIcs",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "304": {
            "description": "Not Modified"
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/tenants/{tenant}/calendar-subscriptions": {
      "get": {
        "tags": [
          "Calendar Subscriptions"
        ],
        "summary": "List Calendar Subscriptions",
        "description": "Lists the current user's external calendar subscriptions. Unpaged — each user holds a handful at most.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListCalendarSubscriptions",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CalendarSubscriptionDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Calendar Subscriptions"
        ],
        "summary": "Create Calendar Subscription",
        "description": "Subscribes the current user to an external calendar by ICS URL. The URL is validated by fetching and parsing it, so a bad link fails here.\n\nRequires: ViewAll on Tasks.",
        "operationId": "CreateCalendarSubscription",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCalendarSubscriptionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarSubscriptionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/calendar-subscriptions/events": {
      "get": {
        "tags": [
          "Calendar Subscriptions"
        ],
        "summary": "List External Calendar Events",
        "description": "Expands the current user's visible subscriptions into concrete events for a date window (100 days at most). A feed that fails to fetch contributes no events; its failure is recorded on the subscription.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListExternalCalendarEvents",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "startDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 100
          },
          {
            "name": "endDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 101
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalCalendarEventDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/calendar-subscriptions/{code}": {
      "get": {
        "tags": [
          "Calendar Subscriptions"
        ],
        "summary": "Get Calendar Subscription",
        "description": "Gets one of the current user's calendar subscriptions by code.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetCalendarSubscription",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarSubscriptionDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Calendar Subscriptions"
        ],
        "summary": "Update Calendar Subscription",
        "description": "Updates one of the current user's calendar subscriptions. A changed URL is re-validated by fetching it.\n\nRequires: ViewAll on Tasks.",
        "operationId": "UpdateCalendarSubscription",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCalendarSubscriptionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarSubscriptionDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "delete": {
        "tags": [
          "Calendar Subscriptions"
        ],
        "summary": "Delete Calendar Subscription",
        "description": "Deletes one of the current user's calendar subscriptions.\n\nRequires: ViewAll on Tasks.",
        "operationId": "DeleteCalendarSubscription",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/calendar-subscriptions/{code}/refresh": {
      "post": {
        "tags": [
          "Calendar Subscriptions"
        ],
        "summary": "Refresh Calendar Subscription",
        "description": "Fetches the subscription's feed again immediately, bypassing the server-side cache. A failed fetch is recorded on the subscription and returned as a 400.\n\nRequires: ViewAll on Tasks.",
        "operationId": "RefreshCalendarSubscription",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarSubscriptionDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/charity-commission/search": {
      "get": {
        "tags": [
          "Charity Commission"
        ],
        "summary": "Search",
        "description": "Search the Charity Commission (England and Wales) register for charities whose name contains the query. Registered charities only, first 20 matches.\n\nRequires: ViewAll on Clients.",
        "operationId": "SearchCharities",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CharitySearchResult"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/charity-commission/{charityNumber}": {
      "get": {
        "tags": [
          "Charity Commission"
        ],
        "summary": "Get Charity Details",
        "description": "Retrieve a charity's register entry by Charity Commission number (6-7 digits, with an optional -N linked-charity suffix). OSCR and CCNI numbers are rejected: only the England and Wales register is available.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCharityDetails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "charityNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Charity"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/charity-commission/{charityNumber}/key-dates": {
      "get": {
        "tags": [
          "Charity Commission"
        ],
        "summary": "Get Charity Key Dates",
        "description": "The charity's register filings mapped to client key dates: annual return due and accounts due for the latest financial period, the dates the last annual return and accounts were received, and the latest financial year end. Nothing is written; the web app saves confirmed rows through the client-dates update.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCharityKeyDates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "charityNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientDateDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/charity-commission/{charityNumber}/trustees": {
      "get": {
        "tags": [
          "Charity Commission"
        ],
        "summary": "Get Charity Trustees",
        "description": "Retrieve a charity's current trustees from the register: name, chair flag, appointment date and the other charities each also acts for. One entry per person. Nothing is written; the web app creates contacts through the client-contacts endpoints.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCharityTrustees",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "charityNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CharityTrustee"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/agent-authorisations": {
      "get": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "List Agent Authorisations",
        "description": "Returns all 11 HMRC 64-8 agent authorisation types for the specified client, each with a user-managed status and a computed IsRequired flag derived from the client's active or proposed services.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetClientAgentAuthorisationStatuses",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientAgentAuthorisationDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "Update Agent Authorisations",
        "description": "Updates the status of one or more HMRC 64-8 agent authorisation types for the specified client. Only the types included in the request are updated; others are left unchanged. Returns the full list of all 11 types.\n\nRequires: Update on Clients.",
        "operationId": "UpdateClientAgentAuthorisationStatuses",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/UpdateClientAgentAuthorisationRequest"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientAgentAuthorisationDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/agent-authorisations/hmrc-request": {
      "post": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "Send HMRC Authorisation Requests",
        "description": "Creates HMRC agent authorisation requests for the specified types. Digital types (MTD-IT, MTD-VAT) create invitations via the REST API and email the client. Letter-based types (SA, CT, PAYE/CIS) submit via the GovTalk XML API and HMRC posts a code to the client.\n\nRequires: Update on Clients.",
        "operationId": "SendHmrcAuthorisationRequests",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendHmrcAuthorisationRequestDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcBatchRequestResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/agent-authorisations/hmrc-submit-code": {
      "post": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "Submit Letter Auth Code",
        "description": "Submits the authorisation code that HMRC posted to the client (letter-based SA, CT, PAYE/CIS flow). On success the authorisation status is set to Granted.\n\nRequires: Update on Clients.",
        "operationId": "SubmitLetterAuthCode",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitLetterAuthCodeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/agent-authorisations/hmrc-send-code-link": {
      "post": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "Send Code Entry Link",
        "description": "Emails the client a secure link for entering the authorisation codes HMRC posted to them. One link covers every letter-based request the client is waiting on. Requires client code entry to be switched on in settings.\n\nRequires: Update on Clients.",
        "operationId": "SendAuthCodeEntryLink",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/agent-authorisations/hmrc-reissue-code/{authorisationType}": {
      "post": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "Reissue Letter Auth Code",
        "description": "Requests HMRC to re-issue an authorisation code for a pending letter-based request. HMRC will post a new code to the client.\n\nRequires: Update on Clients.",
        "operationId": "ReissueLetterAuthCode",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "authorisationType",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AgentAuthorisationType"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/agent-authorisations/hmrc-confirm-held/{authorisationType}": {
      "post": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "Confirm HMRC Authorisation Held",
        "description": "Marks a letter-based request as granted when the authorisation is already in place at HMRC without the code having come through SodiumHQ (for example, entered on HMRC Online Services). Only a request awaiting a posted code can be confirmed.\n\nRequires: Update on Clients.",
        "operationId": "ConfirmHmrcAuthorisationHeld",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "authorisationType",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AgentAuthorisationType"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/agent-authorisations/hmrc-request/{authorisationType}": {
      "delete": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "Cancel HMRC Authorisation Request",
        "description": "Cancels a pending HMRC agent authorisation request and resets the record status to Not Requested. A digital invitation is withdrawn at HMRC; a letter-based request is abandoned locally, as HMRC's letter service has no cancel.\n\nRequires: Update on Clients.",
        "operationId": "CancelHmrcAuthorisationRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "authorisationType",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AgentAuthorisationType"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/agent-authorisations/hmrc-deauthorise/{authorisationType}": {
      "delete": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "Deauthorise HMRC Authorisation",
        "description": "Removes an existing HMRC agent authorisation and resets the record status.\n\nRequires: Update on Clients.",
        "operationId": "DeauthoriseHmrcAuthorisation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "authorisationType",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AgentAuthorisationType"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/agent-authorisations/verify": {
      "post": {
        "tags": [
          "Client - Agent Authorisations"
        ],
        "summary": "Verify Authorisation With HMRC",
        "description": "Asks HMRC whether the practice currently holds a Making Tax Digital authorisation for this client, and in what capacity. A confirmation sets the status to Granted and records the identifier HMRC matched. HMRC not recognising the authorisation never changes the stored status — the result is recorded for review, because it is equally consistent with an out-of-date postcode or National Insurance number held for the client.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "VerifyMtdAuthorisation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyMtdAuthorisationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdVerificationItemDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/billinglineitems/clientbillinglineitem": {
      "get": {
        "tags": [
          "Client - Billing - Lines"
        ],
        "summary": "List Billing Line Items for Client",
        "description": "Lists all Billing Line Items for the specified client.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "ListClientBillingLineItemsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientBillingLineItemSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by line item status (Pending, Approved, Invoiced, Cancelled)",
            "schema": {
              "enum": [
                "Pending",
                "Approved",
                "Invoiced",
                "Cancelled"
              ],
              "type": "string",
              "example": "Pending"
            }
          },
          {
            "name": "clientBillableServiceCode",
            "in": "query",
            "description": "Filter by client billable service code",
            "schema": {
              "type": "string",
              "example": "cbs-001"
            }
          },
          {
            "name": "billableServiceCode",
            "in": "query",
            "description": "Filter by billable service code",
            "schema": {
              "type": "string",
              "example": "bs-001"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "ABC123"
            }
          },
          {
            "name": "billingDateFrom",
            "in": "query",
            "description": "Filter to line items with billing date on or after this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2025-01-01"
            }
          },
          {
            "name": "billingDateTo",
            "in": "query",
            "description": "Filter to line items with billing date on or before this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2025-12-31"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingLineItemDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Billing - Lines"
        ],
        "summary": "Create Billing Line Item for Client",
        "description": "Creates a billing line item for the client. With invoiceNow, the line is created approved and invoiced straight away on its own invoice; a failed push still creates the line and comes back in invoiceError.\n\nRequires: Create on ClientBilling.",
        "operationId": "CreateClientBillingLineItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientBillingLineItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedClientBillingLineItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/billinglineitems/clientbillinglineitem/{code}": {
      "get": {
        "tags": [
          "Client - Billing - Lines"
        ],
        "summary": "Get Billing Line Item for Client",
        "description": "Gets a Billing Line Item for the specified client.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "GetClientBillingLineItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingLineItemDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Billing - Lines"
        ],
        "summary": "Update Billing Line Item for Client",
        "description": "Updates the specified Billing Line Item for the specified client.\n\nRequires: Update on ClientBilling.",
        "operationId": "UpdateClientBillingLineItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientBillingLineItemRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingLineItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Billing - Lines"
        ],
        "summary": "Delete Billing Line Item for Client",
        "description": "Deletes a Billing Line Item for the specified client.\n\nRequires: Delete on ClientBilling.",
        "operationId": "DeleteClientBillingLineItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/billinglineitems": {
      "delete": {
        "tags": [
          "Client - Billing - Lines"
        ],
        "summary": "Bulk Delete Billing Line Items",
        "description": "Deletes several of the client's billing line items. All must exist and none may be invoiced; otherwise nothing is deleted.\n\nRequires: Delete on ClientBilling.",
        "operationId": "BulkDeleteClientBillingLineItems",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkDeleteClientBillingLineItemsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeleteResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/billinglineitems/invoice": {
      "post": {
        "tags": [
          "Client - Billing - Lines"
        ],
        "summary": "Invoice Billing Line Items Now",
        "description": "Invoices the selected line items now, together on one invoice dated invoiceDate. Pending lines are approved first. Refused, with nothing changed, when a line is invoiced, cancelled or already on a submission, or the client cannot be invoiced. A failed push comes back in the result, not as an error.\n\nRequires: Create on ClientBilling.",
        "operationId": "InvoiceClientBillingLineItems",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceClientBillingLineItemsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceSubmissionResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/billinglineitems/{code}/status": {
      "patch": {
        "tags": [
          "Client - Billing - Lines"
        ],
        "summary": "Update Billing Line Item Status",
        "description": "Updates the status of a billing line item. Use to approve or cancel a pending line item.\n\nRequires: Update on ClientBilling.",
        "operationId": "UpdateClientBillingLineItemStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientBillingLineItemStatusRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/billingschedule/clientbillingscheduleitem": {
      "get": {
        "tags": [
          "Client - Billing - Schedule"
        ],
        "summary": "List Billing Schedule Items for Client",
        "description": "Lists all Billing Schedule Items for the specified client.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "ListClientBillingScheduleItemsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientBillingScheduleSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by schedule item status (Scheduled, Billed, Skipped)",
            "schema": {
              "enum": [
                "Scheduled",
                "Billed",
                "Skipped"
              ],
              "type": "string",
              "example": "Scheduled"
            }
          },
          {
            "name": "billingDateFrom",
            "in": "query",
            "description": "Filter to items with a billing date on or after this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2026-01-01"
            }
          },
          {
            "name": "billingDateTo",
            "in": "query",
            "description": "Filter to items with a billing date on or before this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2026-12-31"
            }
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Filter to the charges of one client service, including the package it bills under",
            "schema": {
              "type": "string",
              "example": "cbs_a1b2c3"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingScheduleItemDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Billing - Schedule"
        ],
        "summary": "Create Billing Schedule Item for Client",
        "description": "Creates a new Billing Schedule Item for the specified client.\n\nRequires: Create on ClientBilling.",
        "operationId": "CreateClientBillingScheduleItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAdHocChargeRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingScheduleItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/billingschedule/clientbillingscheduleitem/{code}": {
      "get": {
        "tags": [
          "Client - Billing - Schedule"
        ],
        "summary": "Get Billing Schedule Item for Client",
        "description": "Gets a Billing Schedule Item for the specified client.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "GetClientBillingScheduleItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingScheduleItemDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Billing - Schedule"
        ],
        "summary": "Update Billing Schedule Item for Client",
        "description": "Updates the specified Billing Schedule Item for the specified client.\n\nRequires: Update on ClientBilling.",
        "operationId": "UpdateClientBillingScheduleItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientBillingScheduleItemRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingScheduleItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/billingschedule/{code}/skip": {
      "post": {
        "tags": [
          "Client - Billing - Schedule"
        ],
        "summary": "Skip Billing Schedule Item",
        "description": "Marks one scheduled occurrence as skipped. It is kept as a tombstone so the same period is never generated again.\n\nRequires: Update on ClientBilling.",
        "operationId": "SkipClientBillingScheduleItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingScheduleItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/billingschedule/{code}/bill-now": {
      "post": {
        "tags": [
          "Client - Billing - Schedule"
        ],
        "summary": "Bill Schedule Item Now",
        "description": "Creates the billing line for one scheduled occurrence immediately, ahead of its billing date.\n\nRequires: Update on ClientBilling.",
        "operationId": "BillClientBillingScheduleItemNow",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingScheduleItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/invoicesubmissions/clientinvoicesubmission": {
      "get": {
        "tags": [
          "Client - Billing - Submissions"
        ],
        "summary": "List Invoice Submissions for Client",
        "description": "Lists all Invoice Submissions for the specified client.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "ListClientInvoiceSubmissionsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientInvoiceSubmissionSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by submission status (Pending, Submitted, Failed)",
            "schema": {
              "enum": [
                "Pending",
                "Submitted",
                "Failed",
                "Projected"
              ],
              "type": "string",
              "example": "Failed"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "client-abc"
            }
          },
          {
            "name": "billingDateFrom",
            "in": "query",
            "description": "Filter to submissions with billing date on or after this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2025-01-01"
            }
          },
          {
            "name": "billingDateTo",
            "in": "query",
            "description": "Filter to submissions with billing date on or before this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2025-12-31"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientInvoiceSubmissionDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/invoicesubmissions/clientinvoicesubmission/{code}": {
      "get": {
        "tags": [
          "Client - Billing - Submissions"
        ],
        "summary": "Get Invoice Submission for Client",
        "description": "Gets a Invoice Submission for the specified client.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "GetClientInvoiceSubmissionForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientInvoiceSubmissionDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Billing - Submissions"
        ],
        "summary": "Delete Invoice Submission for Client",
        "description": "Deletes a Invoice Submission for the specified client.\n\nRequires: Delete on ClientBilling.",
        "operationId": "DeleteClientInvoiceSubmissionForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/invoicesubmissions/projected": {
      "get": {
        "tags": [
          "Client - Billing - Submissions"
        ],
        "summary": "Get Projected Invoice Submissions",
        "description": "Returns projected invoice submissions that the overnight process would create for this client. Each entry represents a billing date group of approved, unsubmitted line items.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "GetProjectedInvoiceSubmissionsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientInvoiceSubmissionDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/invoicesubmissions/submit": {
      "post": {
        "tags": [
          "Client - Billing - Submissions"
        ],
        "summary": "Submit Invoice for Client",
        "description": "Creates and pushes a single invoice submission for the specified billing date.\n\nRequires: Create on ClientBilling.",
        "operationId": "SubmitInvoicesForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitInvoiceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceSubmissionResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/invoicesubmissions/{code}/retry": {
      "post": {
        "tags": [
          "Client - Billing - Submissions"
        ],
        "summary": "Retry Failed Submission",
        "description": "Retries a failed invoice submission by re-pushing it to the accounting platform.\n\nRequires: Create on ClientBilling.",
        "operationId": "RetryInvoiceSubmission",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceSubmissionResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/link": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Get Books Link",
        "description": "Returns the organisation this client's record is bound to in their own accounting software, or 404 when they are not connected to any. The connection status tells you whether the figures can currently be read.\n\nRequires at least one of: ViewAll on ClientBooksConnections or ViewAll on ClientBooks.",
        "operationId": "GetClientBooksLink",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBooksLinkDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "ClientBooksConnections",
              "permission": "ViewAll"
            },
            {
              "entity": "ClientBooks",
              "permission": "ViewAll"
            }
          ]
        ]
      },
      "post": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Link Books",
        "description": "Binds the client to one organisation reachable through an existing connection. The organisation is confirmed with the platform before the link is saved. A client can be bound to one organisation, and an organisation to one client.\n\nRequires: Create on ClientBooksConnections.",
        "operationId": "LinkClientBooks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkClientBooksRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBooksLinkDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooksConnections",
            "permission": "Create"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Unlink Books",
        "description": "Removes the client's binding. The underlying connection is left alone — other clients may reach their own organisations through the same one.\n\nRequires: Delete on ClientBooksConnections.",
        "operationId": "UnlinkClientBooks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooksConnections",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/available-organisations": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "List Available Organisations",
        "description": "Lists the organisations the practice's existing accounting connections can reach, asked of each platform live. The ones that cannot be chosen carry an unavailableReason: the organisation used as the practice's own books, or one already linked to another client. Usable ones come first. Only connections whose grant spans several organisations are consulted. On single-organisation platforms use the connect endpoint instead. Pass 'platform' to ask only that platform's connections.\n\nRequires: Create on ClientBooksConnections.",
        "operationId": "GetAvailableBooksOrganisations",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "platform",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AvailableBooksOrganisationDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooksConnections",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/connect": {
      "post": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Connect Client Books",
        "description": "Starts a fresh authorisation aimed at this client's own accounting software and returns the connection, including the authorisation URL to send the browser to. This is the only route on platforms where one authorisation covers a single company — the client's own login is needed there. When the platform reports exactly one organisation, the client is linked to it automatically once the flow completes.\n\nRequires: Create on ClientBooksConnections.",
        "operationId": "StartClientBooksConnection",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartClientBooksConnectionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThirdPartyConnectionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooksConnections",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/invoices": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "List Books Invoices",
        "description": "Lists the sales invoices in the client's own books, most recent first. Paged like any other list: pass 'offset' and 'limit' and you get exactly that window, whatever page size the platform behind it uses. 'totalCount' is null on platforms that report no total — read 'hasMore' rather than inferring the end from a short page. Pass 'status' to list only invoices in one status; the platform does the filtering, so the window and total are of the matching invoices (a status the platform never produces is an empty list). Pass 'dateRange' (a PresetDateRange) to list only invoices dated in that period, or dateRange=CustomDateRange with 'dateFrom' and 'dateTo' (inclusive).\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksInvoices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/InvoiceStatus"
            },
            "x-order": 200
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "dateFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "dateRange",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PresetDateRange"
            },
            "x-order": 400
          },
          {
            "name": "dateTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/bills": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "List Books Bills",
        "description": "Lists the bills (purchase invoices) in the client's own books, most recent first: what the client owes its suppliers. Paged and filtered exactly like the invoices endpoint: 'offset' and 'limit' give that window, 'totalCount' may be null (read 'hasMore'), 'status' and 'dateRange' (or dateRange=CustomDateRange with 'dateFrom' and 'dateTo') are answered by the platform. Statuses are the invoice ones; Overdue here means the client has not paid the supplier by the due date, and a status no bill can be in on that platform (Draft on FreeAgent or QuickBooks, say) is an empty list.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksBills",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/InvoiceStatus"
            },
            "x-order": 200
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "dateFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "dateRange",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PresetDateRange"
            },
            "x-order": 400
          },
          {
            "name": "dateTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksBillDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/ageing": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Get Books Debtors And Creditors",
        "description": "Ages everything outstanding in the client's own books as at today: 'receivables' (what customers owe the client, from unpaid sales invoices) and 'payables' (what the client owes suppliers, from unpaid bills). Each side is split into Current (not yet due) and 1-30, 31-60, 61-90 and over 90 days past the due date, with totals and a breakdown by contact. Each side is a list with one entry per currency, largest first, because amounts in different currencies are never added together; almost always it holds one. Worked out by Sodium from the outstanding documents, so it is the same on every platform, but credit notes and unallocated payments are not netted off and it can differ from the platform's own aged reports. Reads every outstanding invoice and bill, so it is slower than the list endpoints.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksAgeing",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksAgeingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/outstanding-totals": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Get Books Outstanding Totals",
        "description": "What customers owe the client ('receivables') and what the client owes suppliers ('payables'), as two totals read from the client's balance sheet as at today. The link's 'externalUrl' opens the organisation in the platform. For platforms whose metadata says 'supportsBooksTransactionDetail' is false: their terms allow only report-level data from a client's books, so the invoices, bills, ageing and contacts endpoints answer 400 there and this stands in for them. Other platforms answer this one with 400. Unlike the ageing, credit notes and unallocated payments are netted off, as on the balance sheet.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksOutstandingTotals",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksOutstandingTotalsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/contacts": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "List Books Contacts",
        "description": "Lists the contacts in the client's own books. Paged like any other list — see the invoices endpoint for what 'totalCount' being null means.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksContacts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksContactDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/bank-accounts": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "List Books Bank Accounts",
        "description": "Lists the bank accounts in the client's own books. A null balance means the platform does not report one on this endpoint — it is not a zero balance.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksBankAccounts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BooksBankAccountDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/bank-accounts/{bankAccountId}/transactions": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "List Books Bank Transactions",
        "description": "Lists one bank account's transactions in the client's own books over a period, oldest first, to add to a document request as queries. 'bankAccountId' is an id from the bank-accounts list. Name the period as a 'dateRange' (a PresetDateRange), as dateRange=CustomDateRange with 'dateFrom' and 'dateTo' (inclusive), or as bare 'dateFrom' and 'dateTo'; at most 12 months. Pass 'unreconciledOnly' for only what the books have not yet explained, in the platform's own sense (its metadata's 'bankTransactionsUnreconciledLabel'; 400 where that is null). Amounts are signed, money out negative. At most 1,000 lines: 'isTruncated' says the period held more. Only platforms whose metadata says 'bankTransactions' is Available can answer; the rest answer with 400 saying so.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksBankTransactions",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "bankAccountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "dateFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "dateRange",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PresetDateRange"
            },
            "x-order": 400
          },
          {
            "name": "dateTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "unreconciledOnly",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksBankTransactionsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/chart-of-accounts": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "List Books Chart Of Accounts",
        "description": "Lists the client's chart of accounts — every nominal code, its name, and how the platform classifies it. Paged like any other list, and this one always knows its 'totalCount' because the whole chart has to be read to answer at all. 'search' narrows on code and name before the page is cut. The type is the platform's own wording, not a normalised one.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksChartOfAccounts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NominalCodeDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/report-periods": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "List Books Report Periods",
        "description": "Lists every period the profit and loss and the trial balance can be run over, each with the dates it stands for today: the client's own financial years first (each with 'financialPeriod' set), then every PresetDateRange except CustomDateRange (each with 'dateRange' set). Pass the one that is set back to the report to run it over those dates. Worked out without calling the client's accounting software.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksReportPeriods",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BooksReportPeriodDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/profit-and-loss": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Get Books Profit And Loss",
        "description": "Runs a profit and loss report over the client's own books for the period given. Name the period as a 'financialPeriod' (one of the client's own financial years, worked out from their key dates, or the tax year when they have no year end), as a 'dateRange' (a PresetDateRange), as dateRange=CustomDateRange with 'dateFrom' and 'dateTo' (inclusive), or as bare 'dateFrom' and 'dateTo' with no dateRange at all. Sections come back as the platform grouped them rather than normalised into fixed totals. Some platforms offer no such report and answer with 400 saying so.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksProfitAndLoss",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "dateFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "dateRange",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PresetDateRange"
            },
            "x-order": 400
          },
          {
            "name": "dateTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "financialPeriod",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/BooksFinancialPeriod"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksProfitAndLossDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/trial-balance": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Get Books Trial Balance",
        "description": "Runs a trial balance over the client's own books — one signed balance per nominal account, positive for debit and negative for credit, in the platform's own order. The period is named the same way as the profit and loss endpoint's. Only platforms whose metadata says 'supportsTrialBalance' can answer; the rest answer with 400 saying so.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksTrialBalance",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "dateFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "dateRange",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PresetDateRange"
            },
            "x-order": 400
          },
          {
            "name": "dateTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "financialPeriod",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/BooksFinancialPeriod"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksTrialBalanceDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/balance-sheet": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Get Books Balance Sheet",
        "description": "Runs a balance sheet over the client's own books as at one date — 'asAt', defaulting to today. A statement of position, so unlike the profit and loss it takes a single date rather than a period. The 'asAt' that comes back is the date the platform actually ran to, which is not always the one asked for: Xero's report runs to a month end, so a mid-month date is answered as at that month's end. Sections come back as the platform grouped them, and a section with a title and no lines is a heading it emitted. Only platforms whose metadata says 'supportsBalanceSheet' can answer; the rest answer with 400 saying so.\n\nRequires: ViewAll on ClientBooks.",
        "operationId": "GetClientBooksBalanceSheet",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "asAt",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooksBalanceSheetDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/bookkeeping/link": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Get Bookkeeping Link",
        "description": "Returns the organisation this client's record is bound to at the practice's bookkeeping health provider, or 404 when they are not linked. The connection status tells you whether the figures can currently be read.\n\nRequires: ViewAll on BookkeepingHealth.",
        "operationId": "GetClientBookkeepingLink",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBookkeepingLinkDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BookkeepingHealth",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Link Bookkeeping",
        "description": "Binds the client to one organisation at the practice's bookkeeping health provider. The organisation is confirmed with the provider before the link is saved. A client can be bound to one organisation, and an organisation to one client.\n\nRequires: Create on BookkeepingHealth.",
        "operationId": "LinkClientBookkeeping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkClientBookkeepingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBookkeepingLinkDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BookkeepingHealth",
            "permission": "Create"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Unlink Bookkeeping",
        "description": "Removes the client's binding. The underlying connection is left alone — other clients reach their own organisations through the same one.\n\nRequires: Delete on BookkeepingHealth.",
        "operationId": "UnlinkClientBookkeeping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BookkeepingHealth",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/bookkeeping/available-organisations": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "List Available Bookkeeping Organisations",
        "description": "Lists the organisations the practice's bookkeeping health connection can score and that are free to link, asked of the provider live. Excludes any organisation already linked to another client. Unranked — ordering the likely match first is a display concern.\n\nRequires: Create on BookkeepingHealth.",
        "operationId": "GetAvailableBookkeepingOrganisations",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AvailableBookkeepingOrganisationDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BookkeepingHealth",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/books/bookkeeping/health": {
      "get": {
        "tags": [
          "Client - Books"
        ],
        "summary": "Get Bookkeeping Health",
        "description": "Returns the provider's scoring of the client's books — health percentage, issue count and value at risk per time bucket, plus activity figures — quality and activity combined in one response so a bucket selector needs no further calls. The bucket names are the provider's own strings and the two lists' bucket sets differ; join by duration and expect gaps. Served through a short server-side cache — 'retrievedAt' says when the figures were actually fetched.\n\nRequires: ViewAll on BookkeepingHealth.",
        "operationId": "GetClientBookkeepingHealth",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookkeepingHealthDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BookkeepingHealth",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/businessdetails": {
      "get": {
        "tags": [
          "Client - Business Details"
        ],
        "summary": "Get BusinessDetails for a client",
        "description": "Requires: ViewAll on Clients.",
        "operationId": "GetBusinessDetailsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessDetailsDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Business Details"
        ],
        "summary": "Update BusinessDetails for a client",
        "description": "Requires: Update on Clients.",
        "operationId": "UpdateBusinessDetailsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BusinessDetailsDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessDetailsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/businessdetails/vat-number/verify": {
      "post": {
        "tags": [
          "Client - Business Details"
        ],
        "summary": "Verify Client VAT Number",
        "description": "Checks the client's VAT number against HMRC's Check a UK VAT Number service and records the outcome on their business details. When the practice's own VAT number is set on Practice Details the check is a verified one and HMRC's consultation number (proof of the check) is stored. A \"not registered\" answer is returned as registered=false, and clears any earlier verification. Editing the VAT number clears the verification automatically.\n\nRequires: Update on Clients.",
        "operationId": "VerifyClientVatNumber",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VatNumberVerificationDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-confirmations": {
      "get": {
        "tags": [
          "Client - Confirmations"
        ],
        "summary": "List Client Confirmations",
        "description": "Returns a paged list of client confirmation workflow steps across all clients. Filter by status and client code.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListClientConfirmations",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientConfirmationSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by status (NotStarted, InProgress, Blocked, Completed, Skipped)",
            "schema": {
              "enum": [
                "NotStarted",
                "InProgress",
                "Blocked",
                "Completed",
                "Skipped"
              ],
              "type": "string",
              "example": "InProgress"
            }
          },
          {
            "name": "managerCode",
            "in": "query",
            "description": "Filter by client manager user code",
            "schema": {
              "type": "string",
              "example": "USR001"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter by client partner user code",
            "schema": {
              "type": "string",
              "example": "USR002"
            }
          },
          {
            "name": "taskCategoryCode",
            "in": "query",
            "description": "Filter by task category code",
            "schema": {
              "type": "string",
              "example": "CAT001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across step name, task title, and client name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "tax return"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientConfirmationDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientcontact": {
      "get": {
        "tags": [
          "Client - Contacts"
        ],
        "summary": "List Contacts for Client",
        "description": "Lists all Contacts for the specified client.\n\nRequires: ViewAll on ClientContacts.",
        "operationId": "ListClientContactsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientContactSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "type",
            "in": "query",
            "description": "Filter by contact type",
            "schema": {
              "enum": [
                "Main",
                "Billing",
                "Payroll",
                "Accounts",
                "Director",
                "Psc",
                "Secretary",
                "Trustee"
              ],
              "type": "string",
              "example": "Main"
            }
          },
          {
            "name": "role",
            "in": "query",
            "description": "Filter by contact role",
            "schema": {
              "type": "string",
              "example": "Project Manager"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across contact details: name, email, code (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "john"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientContactDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientContacts",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Contacts"
        ],
        "summary": "Create Contact for Client",
        "description": "Creates a client-contact relationship. If Contact.Code is provided and matches an existing contact, that contact will be linked to this client. If Contact.Code is not provided (or empty), a new Contact will be created using the provided contact details (FirstName, LastName, Email, etc.) and then linked to this client.\n\nRequires: Create on ClientContacts.",
        "operationId": "CreateContactForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientContactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientContactDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientContacts",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientcontact/{code}": {
      "get": {
        "tags": [
          "Client - Contacts"
        ],
        "summary": "Get Contact for Client",
        "description": "Gets a Contact for the specified client.\n\nRequires: ViewAll on ClientContacts.",
        "operationId": "GetClientContactForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientContactDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientContacts",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Contacts"
        ],
        "summary": "Update Contact for Client",
        "description": "Updates the specified Contact for the specified client.\n\nRequires: Update on ClientContacts.",
        "operationId": "UpdateClientContactForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientContactRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientContactDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientContacts",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Contacts"
        ],
        "summary": "Delete Contact for Client",
        "description": "Deletes a Contact for the specified client.\n\nRequires: Delete on ClientContacts.",
        "operationId": "DeleteClientContactForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientContacts",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/custom-field-values": {
      "get": {
        "tags": [
          "Client - Custom Fields"
        ],
        "summary": "Get Custom Field Values",
        "description": "Returns field code and value pairs for the specified client. Use the custom field definitions endpoint to retrieve data types, labels, and allowed options.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetClientCustomFieldValues",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomFieldValueDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Custom Fields"
        ],
        "summary": "Set Custom Field Values",
        "description": "Sets or updates custom field values for the specified client. Only fields included in the request are updated. Use the custom field definitions endpoint to determine valid field codes and data types.\n\nRequires: Update on Clients.",
        "operationId": "SetClientCustomFieldValues",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/CustomFieldValueDto"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{code}/dates": {
      "get": {
        "tags": [
          "Client - Dates"
        ],
        "summary": "Get Client Dates",
        "description": "Returns all key dates for the specified client\n\nRequires: ViewAll on Clients.",
        "operationId": "GetClientDates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientDateDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Dates"
        ],
        "summary": "Save Client Dates",
        "description": "Saves or updates key dates for the specified client. Dates with null values will be deleted.\n\nRequires: Update on Clients.",
        "operationId": "SaveClientDates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SaveClientDateDto"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-deadlines": {
      "get": {
        "tags": [
          "Client - Dates"
        ],
        "summary": "List Client Deadlines",
        "description": "Returns the statutory deadlines of active clients between startDate and endDate (inclusive,\nat most one year apart), grouped by date and then by deadline type, with the clients on each.\n\nDeadlines are each client's next due key dates: accounts, confirmation statement, VAT return\n(the annual date as entered; quarterly and monthly computed from the VAT reporting period),\nPAYE/CIS filing, pension re-enrolment and the Charity Commission annual return and accounts.\nDates with no deadlines are omitted. client limits the result to one client. Restricted users\nsee only the clients they can see.\n\nRequires: ViewAll on Clients.",
        "operationId": "ListClientDeadlines",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "startDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 100
          },
          {
            "name": "endDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 101
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientDeadlineDateDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest": {
      "get": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "List Document Requests for Client",
        "description": "Lists all Document Requests for the specified client.\n\nRequires: ViewAll on DocumentRequests.",
        "operationId": "ListDocumentRequestsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/DocumentRequestSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by request status (Draft, Open, Submitted, Accepted, Rejected, Cancelled)",
            "schema": {
              "enum": [
                "Draft",
                "Open",
                "Submitted",
                "Accepted",
                "Rejected",
                "Cancelled"
              ],
              "type": "string",
              "example": "Open"
            }
          },
          {
            "name": "needsReview",
            "in": "query",
            "description": "true: only requests with a submission or answered items to review; false: only those without",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "managerCode",
            "in": "query",
            "description": "Filter by client manager user code",
            "schema": {
              "type": "string",
              "example": "USR001"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter by client partner user code",
            "schema": {
              "type": "string",
              "example": "USR002"
            }
          },
          {
            "name": "taskCategoryCode",
            "in": "query",
            "description": "Filter by task category code",
            "schema": {
              "type": "string",
              "example": "CAT001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across request title and description (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "tax returns"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Create Document Request",
        "description": "Creates a new document request in Draft status for the specified client. Give items to ask for several things, each answered and reviewed on its own; leave them out for a single ask.\n\nRequires: Create on DocumentRequests.",
        "operationId": "CreateDocumentRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocumentRequestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}": {
      "get": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Get Document Request for Client",
        "description": "Gets a Document Request for the specified client.\n\nRequires: ViewAll on DocumentRequests.",
        "operationId": "GetDocumentRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Update Document Request for Client",
        "description": "Updates the specified Document Request for the specified client.\n\nRequires: Update on DocumentRequests.",
        "operationId": "UpdateDocumentRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentRequestRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Delete Document Request for Client",
        "description": "Deletes a Document Request for the specified client.\n\nRequires: Delete on DocumentRequests.",
        "operationId": "DeleteDocumentRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/detail": {
      "get": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Get Document Request Detail",
        "description": "Gets a document request with its associated documents and submission responses.\n\nRequires: ViewAll on DocumentRequests.",
        "operationId": "GetDocumentRequestDetailForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDetailDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/open": {
      "put": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Open Document Request",
        "description": "Transitions a document request from Draft to Open, making it visible to the client. With composedEmail, sends that email (edited from the open preview, keeping its link placeholder) in place of the opened-email template. When scheduledAt is set, the request stays Draft: a scheduled send opens it at that time and 202 is returned.\n\nRequires: Update on DocumentRequests.",
        "operationId": "OpenDocumentRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenDocumentRequestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/open/preview": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Preview Document Request Email",
        "description": "Renders the email a draft document request would be sent to these recipients with: the opened-email template filled in, with a placeholder where each recipient's own link goes. Opens and sends nothing.\n\nRequires: Update on DocumentRequests.",
        "operationId": "PreviewOpenDocumentRequestEmailForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewOpenDocumentRequestEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepEmailPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/resend": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Resend Document Request",
        "description": "Emails an open document request to the given addresses again, each with a fresh link. Everyone the request already went to keeps their link and keeps being chased, unless stopChasingOthers is set, which makes these the only recipients.\n\nRequires: Update on DocumentRequests.",
        "operationId": "ResendDocumentRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResendRequestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/cancel": {
      "put": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Cancel Document Request",
        "description": "Cancels a Draft or Open document request. It stops being chased, leaves the client's outstanding requests, its links stop working and any scheduled send of it is cancelled. Documents already uploaded are kept, and the linked workflow step is not changed. 400 when the request is no longer Draft or Open.\n\nRequires: Update on DocumentRequests.",
        "operationId": "CancelDocumentRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/recipients": {
      "get": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Get Document Request Recipients",
        "description": "Returns the email addresses a document request currently counts as its recipients: everyone it was sent to and has not since been withdrawn from. These are the addresses its chases go to.\n\nRequires: ViewAll on DocumentRequests.",
        "operationId": "GetDocumentRequestRecipientsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestRecipientsDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/documents": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Upload Documents to Request",
        "description": "Uploads one or more documents for the client to the document request as a whole. Each file is uploaded independently — the response reports success or failure per file. 400 for a request with items: upload to an item instead.\n\nRequires: Update on DocumentRequests.",
        "operationId": "UploadDocumentsToRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "files"
                ],
                "type": "object",
                "properties": {
                  "fileDetails": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string",
                    "format": "date"
                  },
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  }
                }
              },
              "encoding": {
                "fileDetails": {
                  "style": "form"
                },
                "date": {
                  "style": "form"
                },
                "files": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentUploadBatchResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/items/{number}/documents": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Upload Documents to Request Item",
        "description": "Uploads one or more documents for the client to one item of a document request. Each file is uploaded independently — the response reports success or failure per file.\n\nRequires: Update on DocumentRequests.",
        "operationId": "UploadDocumentsToRequestItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "files"
                ],
                "type": "object",
                "properties": {
                  "fileDetails": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string",
                    "format": "date"
                  },
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  }
                }
              },
              "encoding": {
                "fileDetails": {
                  "style": "form"
                },
                "date": {
                  "style": "form"
                },
                "files": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentUploadBatchResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/attachments": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Attach Files to Request",
        "description": "Shares one or more files on the document request as a whole, for the client to download, complete and send back. Each file is uploaded independently — the response reports success or failure per file.\n\nRequires: Update on DocumentRequests.",
        "operationId": "AttachFilesToRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "files"
                ],
                "type": "object",
                "properties": {
                  "fileDetails": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string",
                    "format": "date"
                  },
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  }
                }
              },
              "encoding": {
                "fileDetails": {
                  "style": "form"
                },
                "date": {
                  "style": "form"
                },
                "files": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentUploadBatchResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/items/{number}/attachments": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Attach Files to Request Item",
        "description": "Shares one or more files on one item of a document request, for the client to download, complete and send back. Each file is uploaded independently — the response reports success or failure per file.\n\nRequires: Update on DocumentRequests.",
        "operationId": "AttachFilesToRequestItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "files"
                ],
                "type": "object",
                "properties": {
                  "fileDetails": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string",
                    "format": "date"
                  },
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  }
                }
              },
              "encoding": {
                "fileDetails": {
                  "style": "form"
                },
                "date": {
                  "style": "form"
                },
                "files": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentUploadBatchResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/documents/{documentCode}": {
      "delete": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Remove Document from Request",
        "description": "Removes a document from the specified document request.\n\nRequires: Update on DocumentRequests.",
        "operationId": "RemoveDocumentFromRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "documentCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/responses": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Submit Document Request",
        "description": "Submits a response to a document request. Comments are required if no documents are attached. 400 for a request with items: answer an item for the client instead.\n\nRequires: Update on DocumentRequests.",
        "operationId": "SubmitDocumentRequestForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitDocumentRequestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/items": {
      "put": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Save Document Request Items",
        "description": "Saves a Draft request's whole list of items in the order given, numbering them 1 to n. An item carrying the number of an existing item keeps it (and its files); one without is added; existing items left out are removed. An empty list makes the request a single ask again. 400 once the request is sent.\n\nRequires: Update on DocumentRequests.",
        "operationId": "SaveDocumentRequestItemsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentRequestItemsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDetailDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Add Document Request Items",
        "description": "Adds items after the last one: to a Draft, or to a sent request that already has items (a request sent as a single ask stays one). Items added after sending are not emailed to the client: tell them with a notification, or they hear with the next chase. At most 250 items on a request.\n\nRequires: Update on DocumentRequests.",
        "operationId": "AddDocumentRequestItemsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentRequestItemsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDetailDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/items/{number}": {
      "put": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Update Document Request Item",
        "description": "Changes an item's kind, text and transaction details. Once the request is sent, only while the client has not answered the item or saved anything on it.\n\nRequires: Update on DocumentRequests.",
        "operationId": "UpdateDocumentRequestItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentRequestItemInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDetailDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Remove Document Request Item",
        "description": "Removes an item; its files stay on the request. On a Draft the items after it move up a number. Once sent, only an item the client has not touched, and never the last one.\n\nRequires: Update on DocumentRequests.",
        "operationId": "RemoveDocumentRequestItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/reviews": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Review Document Request Items",
        "description": "Applies the practice's decisions on items together: Resolve (any item not yet resolved) or SendBack (an answered item, with a note). Items sent back go to the client in one email unless notifyClient is false. Resolving the last item accepts the request, approves the client's files and completes the workflow step that sent it. 400, changing nothing, when any decision no longer fits its item.\n\nRequires: Update on DocumentRequests.",
        "operationId": "ReviewDocumentRequestItemsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviewDocumentRequestItemsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDetailDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/items/{number}/answers": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Answer Document Request Item",
        "description": "Records an answer a member of staff gives on the client's behalf. Upload any files to the item first; the answer needs text, cannotProvide or a file. The item becomes Answered, for review like any other.\n\nRequires: Update on DocumentRequests.",
        "operationId": "AnswerDocumentRequestItemForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnswerDocumentRequestItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDetailDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/items/{number}/history": {
      "get": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Get Document Request Item History",
        "description": "Who added the item, changed its question, answered it, sent it back or resolved it, and when, newest first. The client's unsent drafts are not included.\n\nRequires: ViewAll on DocumentRequests.",
        "operationId": "GetDocumentRequestItemHistory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DocumentRequestItemHistoryEntryDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/notifications/preview": {
      "get": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Preview Items Email",
        "description": "The email telling the client about added items, for the composer: the practice's opened-email template filled in, a placeholder where each recipient's own link goes, and who it goes to. Sends nothing.\n\nRequires: Update on DocumentRequests.",
        "operationId": "PreviewDocumentRequestNotificationForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepEmailPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/notifications": {
      "post": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Tell Client About Items",
        "description": "Emails everyone a sent request with items went to, each with their own link, that items have been added, and clears itemsChangedSinceNotified. With a body, sends the email as edited from the preview (it must keep the link placeholder); without, sends the opened-email template.\n\nRequires: Update on DocumentRequests.",
        "operationId": "NotifyDocumentRequestItemsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ComposedEmail"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/items/export": {
      "get": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Export Document Request Items",
        "description": "Downloads a request's items and their answers as a CSV file, one row per item.\n\nRequires: ViewAll on DocumentRequests.",
        "operationId": "ExportDocumentRequestItemsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/csv": {
                "schema": {
                  "$ref": "#/components/schemas/FileContentHttpResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/documentrequest/{code}/responses/{responseCode}/review": {
      "put": {
        "tags": [
          "Client - Document Requests"
        ],
        "summary": "Review Document Request Response",
        "description": "Accepts or rejects a submitted response. On rejection, specify the next action: reopen or reopen and clear documents. 400 for a request with items: review each item instead.\n\nRequires: Update on DocumentRequests.",
        "operationId": "ReviewDocumentRequestResponseForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "responseCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviewDocumentRequestResponseRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      }
    },
    "/clientdocument/{code}/stream": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Stream Document Content",
        "description": "Streams document content. Requires a valid signed token with tenant and client as query parameters. Use the optional 'disposition' parameter to control the Content-Disposition header: 'attachment' (default) prompts a file download, 'inline' displays the file in the browser for supported types (e.g. PDF, images). The optional 'version' parameter takes a revision id from the document's version history and streams that revision instead of the current file.",
        "operationId": "StreamClientDocumentForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "disposition",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "expires",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            },
            "x-order": 400
          },
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "version",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/external-file/{externalFileId}/stream": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Stream External File",
        "description": "Proxies and streams file content from an external storage provider. Requires a valid signed token with tenant and client as query parameters.",
        "operationId": "StreamExternalFileForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "disposition",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "expires",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            },
            "x-order": 400
          },
          {
            "name": "externalFileId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "fileName",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "List Documents for Client",
        "description": "Lists all Documents for the specified client.\n\nRequires: ViewAll on ClientDocuments.",
        "operationId": "ListClientDocumentsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientDocumentSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "documentCategoryCode",
            "in": "query",
            "description": "Filter by document category code",
            "schema": {
              "type": "string",
              "example": "engagement-letters"
            }
          },
          {
            "name": "reviewStatus",
            "in": "query",
            "description": "Filter by review status (Approved, PendingReview, Rejected)",
            "schema": {
              "enum": [
                "Approved",
                "PendingReview",
                "Rejected"
              ],
              "type": "string",
              "example": "PendingReview"
            }
          },
          {
            "name": "clientApprovalStatus",
            "in": "query",
            "description": "Filter by client approval status (None, Pending, Approved, Rejected)",
            "schema": {
              "enum": [
                "None",
                "Pending",
                "Approved",
                "Rejected"
              ],
              "type": "string",
              "example": "Pending"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "managerCode",
            "in": "query",
            "description": "Filter by client manager user code",
            "schema": {
              "type": "string",
              "example": "USR001"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter by client partner user code",
            "schema": {
              "type": "string",
              "example": "USR002"
            }
          },
          {
            "name": "taskCategoryCode",
            "in": "query",
            "description": "Filter by task category code",
            "schema": {
              "type": "string",
              "example": "CAT001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across document name and description (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "certificate"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Create Document for Client",
        "description": "Creates a new Document for the specified client.\n\nRequires: Create on ClientDocuments.",
        "operationId": "CreateClientDocumentForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "date",
                  "documentCategoryCode",
                  "file",
                  "requestClientApproval",
                  "summary",
                  "title",
                  "visibleInClientPortal"
                ],
                "type": "object",
                "properties": {
                  "documentCategoryCode": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "summary": {
                    "type": "string"
                  },
                  "date": {
                    "type": "string",
                    "format": "date"
                  },
                  "requestClientApproval": {
                    "type": "boolean"
                  },
                  "visibleInClientPortal": {
                    "type": "boolean"
                  },
                  "recipientEmails": {
                    "type": "string"
                  },
                  "folderId": {
                    "type": "string"
                  },
                  "folderPath": {
                    "type": "string"
                  },
                  "portalFolderPath": {
                    "type": "string"
                  },
                  "chaseFrequencyDays": {
                    "type": "integer",
                    "format": "int32"
                  },
                  "isSavedAttachment": {
                    "type": "boolean"
                  },
                  "storageFolderPath": {
                    "type": "string"
                  },
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "documentCategoryCode": {
                  "style": "form"
                },
                "title": {
                  "style": "form"
                },
                "summary": {
                  "style": "form"
                },
                "date": {
                  "style": "form"
                },
                "requestClientApproval": {
                  "style": "form"
                },
                "visibleInClientPortal": {
                  "style": "form"
                },
                "recipientEmails": {
                  "style": "form"
                },
                "folderId": {
                  "style": "form"
                },
                "folderPath": {
                  "style": "form"
                },
                "portalFolderPath": {
                  "style": "form"
                },
                "chaseFrequencyDays": {
                  "style": "form"
                },
                "isSavedAttachment": {
                  "style": "form"
                },
                "storageFolderPath": {
                  "style": "form"
                },
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/{code}": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Get Document for Client",
        "description": "Gets a Document for the specified client.\n\nRequires: ViewAll on ClientDocuments.",
        "operationId": "GetClientDocumentForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Update Document for Client",
        "description": "Updates the specified Document for the specified client.\n\nRequires: Update on ClientDocuments.",
        "operationId": "UpdateClientDocumentForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientDocumentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Delete Document for Client",
        "description": "Deletes a Document for the specified client.\n\nRequires: Delete on ClientDocuments.",
        "operationId": "DeleteClientDocumentForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/document-filing/{source}": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Get Client Document Filing Default",
        "description": "Where a document of this kind is filed for this client when nobody chooses, worked out from the practice's filing settings (and for a request's uploads, the request's own folders). Shown wherever staff can choose a folder instead. Paths are null for the client's folder and the top of the portal.\n\nRequires at least one of: Create on ClientDocuments or Update on DocumentRequests.",
        "operationId": "GetClientDocumentFilingDefault",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "requestCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "source",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/DocumentFilingSource"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentFilingDefaultDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "ClientDocuments",
              "permission": "Create"
            },
            {
              "entity": "DocumentRequests",
              "permission": "Update"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/external-files": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "List External Files",
        "description": "Lists files from the client's external storage folder, enriched with metadata from the database for files tracked by Sodium. Returns 404 if the tenant has no external storage or the platform doesn't support file listing.\n\nRequires: ViewAll on ClientDocuments.",
        "operationId": "ListExternalFilesForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "folderId",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalDocumentDtoPagedResult"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/external-folders": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Create External Folder",
        "description": "Creates a folder in the client's external storage folder. Pass `parentFolderId` to create it inside a subfolder; omit it to create at the top level of the client's folder. Returns 404 if the tenant has no external storage or the client has no folder mapped.\n\nRequires: Update on ClientDocuments.",
        "operationId": "CreateExternalFolderForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateExternalFolderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionFolderDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/external-files/move": {
      "put": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Move External Files",
        "description": "Moves files into a different folder in the practice's external storage. Set `portalFolderPath` to also move the tracked documents to that folder in the client portal; omit it to leave portal locations untouched. Returns 400 if the platform does not support moving files.\n\nRequires: Update on ClientDocuments.",
        "operationId": "MoveExternalFilesForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MoveExternalFilesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MoveExternalFilesResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/document-folder": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Get Client Document Folder",
        "description": "Gets the external folder reference for a client's documents. This is only relevant if an external Document Storage provider has been set for the Tenant\n\nRequires: ViewAll on ClientDocuments.",
        "operationId": "GetClientDocumentFolder",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalFolderReferenceDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Set Client Document Folder",
        "description": "Updates the external folder reference for a client's documents. This is only relevant if an external Document Storage provider has been set for the Tenant\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "UpsertClientDocumentFolder",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertBaseFolderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalFolderReferenceDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Unmap Client Document Folder",
        "description": "Removes the external folder reference for a client's documents. The folder and its files are not deleted from the external storage provider.\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "DeleteClientDocumentFolder",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/{code}/review": {
      "put": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Review Document",
        "description": "Approve or reject a document uploaded by a client via the portal.\n\nRequires: Update on ClientDocuments.",
        "operationId": "ReviewClientDocumentForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviewClientDocumentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/notify": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Notify Client of Documents",
        "description": "Sends the specified recipients a single email with a secure link to each document, optionally attaching the files. Completes a linked Upload a Document workflow step.\n\nRequires: Update on ClientDocuments.",
        "operationId": "NotifyClientForDocuments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotifyClientDocumentsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientDocumentDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/request-approval": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Request Client Approval",
        "description": "Sends one or more documents to a client for approval. The documents appear in the client portal for approval. In Batch mode they form a single approval request the client approves or rejects in one go, and the request is rejected outright if any document is ineligible. In Individual mode each document gets its own approval request and the response reports each one separately. When scheduledAt is set, nothing happens now: the documents stay untouched, a scheduled send dispatches the request at that time and 202 is returned.\n\nRequires: Update on ClientDocuments.",
        "operationId": "RequestClientApprovalForDocuments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequestClientApprovalForDocumentsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestClientApprovalForDocumentsResultDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/request-approval/preview": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Preview Approval Email",
        "description": "Renders the approval email for these documents so the user can review and edit it before sending. Nothing is created or sent. The body holds a placeholder where each recipient's own link goes at send time.\n\nRequires: Update on ClientDocuments.",
        "operationId": "PreviewClientApprovalEmail",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewClientApprovalEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepEmailPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/approval-batches/{batchCode}/cancel": {
      "put": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Cancel Batch Approval Request",
        "description": "Cancels a pending batch approval request, resetting every document still awaiting the client. The documents stay shared in the client portal unless the body asks to remove them.\n\nRequires: Update on ClientDocuments.",
        "operationId": "CancelClientApprovalBatch",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "batchCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelClientApprovalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentApprovalBatchDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/approval-batches/{batchCode}/resend": {
      "put": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Resend Batch Approval Request",
        "description": "Emails a pending portal approval request to the given addresses again, each with a fresh link. Everyone the request already went to keeps their link and keeps being chased, unless stopChasingOthers is set, which makes these the only recipients. E-signature requests are refused: their signers are managed on the signing platform.\n\nRequires: Update on ClientDocuments.",
        "operationId": "ResendClientApprovalBatch",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "batchCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResendRequestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentApprovalBatchDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/approval-batches/{batchCode}/recipients": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Get Batch Approval Request Recipients",
        "description": "Returns the email addresses a portal approval request currently counts as its recipients: everyone it was sent to and has not since been withdrawn from. These are the addresses its chases go to.\n\nRequires: ViewAll on ClientDocuments.",
        "operationId": "GetClientApprovalBatchRecipients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "batchCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestRecipientsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/{code}/cancel-approval": {
      "put": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Cancel Client Approval Request",
        "description": "Cancel a pending client approval request, resetting the document to no approval status. When the document was sent alongside others, only this document is withdrawn — the rest of the request stands. The document stays shared in the client portal unless the body asks to remove it.\n\nRequires: Update on ClientDocuments.",
        "operationId": "CancelClientApprovalForDocument",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelClientApprovalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/portal-view": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Get Portal View",
        "description": "Returns documents and folders as they would appear in the client portal, grouped by PortalFolderPath. Use the portalFolderPath query param to navigate into sub-folders.\n\nRequires: ViewAll on ClientDocuments.",
        "operationId": "GetClientDocumentPortalView",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "portalFolderPath",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentPortalViewResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/portal-folder": {
      "put": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Move Documents to Portal Folder",
        "description": "Changes which client portal folder the given documents appear in. Pass an empty or omitted `portalFolderPath` to move them to the portal root. Portal folders are virtual, so moving the last document out of a folder removes that folder from the portal. The physical file in external storage is not moved.\n\nRequires: Update on ClientDocuments.",
        "operationId": "MoveDocumentsToPortalFolderForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MoveDocumentsToPortalFolderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MoveDocumentsToPortalFolderResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/portal-visibility": {
      "patch": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Set Documents Portal Visibility",
        "description": "Shows or hides the given documents in the client portal. Documents already in the requested state are unaffected, and a document pending client approval cannot be hidden. Visibility is metadata only — the file in external storage is not moved or changed.\n\nRequires: Update on ClientDocuments.",
        "operationId": "SetDocumentsPortalVisibilityForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetDocumentsPortalVisibilityRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentBulkActionResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/bulk-track-external": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Bulk Track External Files",
        "description": "Creates document records for files that already exist in the external storage provider. No file upload — titles are derived from the file names. Files are tracked independently, so the result can contain a mix of successes and failures; files already tracked fail individually.\n\nRequires: Create on ClientDocuments.",
        "operationId": "BulkTrackExternalFilesForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkTrackExternalFilesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentBulkActionResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/bulk-delete": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Bulk Delete Documents",
        "description": "Deletes the given documents, including their stored files. Documents are deleted independently, so the result can contain a mix of successes and failures.\n\nRequires: Delete on ClientDocuments.",
        "operationId": "BulkDeleteClientDocumentsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkDeleteClientDocumentsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentBulkActionResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/from-template": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Create Document from Template",
        "description": "Generates a PDF from a document template using client data and custom token values, then saves it as a client document.\n\nRequires: Create on ClientDocuments.",
        "operationId": "CreateClientDocumentFromTemplateForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientDocumentFromTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/from-template/editable-html": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Render Template for Editing",
        "description": "Returns the template's body with the client's data filled in, to edit before creating the document. Send the edited HTML back as editedHtml on the from-template routes. Saves nothing.\n\nRequires: Create on ClientDocuments.",
        "operationId": "RenderClientDocumentEditableHtmlForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientDocumentFromTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentEditableHtmlDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/from-template/preview-pdf": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Preview Document from Template",
        "description": "Returns the PDF the from-template route would create, including any edited HTML. Saves nothing.\n\nRequires: Create on ClientDocuments.",
        "operationId": "PreviewClientDocumentFromTemplateForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientDocumentFromTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/track-external": {
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Track External File",
        "description": "Creates a document record for a file that already exists in the external storage provider. No file upload — just associates the external file with Sodium metadata (title, category, visibility, etc.).\n\nRequires: Create on ClientDocuments.",
        "operationId": "TrackExternalFileForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TrackExternalFileRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientdocument/{code}/versions": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "List Document Versions",
        "description": "Returns the document's file history as the practice's storage provider keeps it, newest first, each revision with its own signed download URL. Sodium stores no copies of superseded files, so this is read live from the provider and reflects whatever that account has retained. Empty for a document Sodium stores itself, or one on a platform with no readable version history.\n\nRequires: ViewAll on ClientDocuments.",
        "operationId": "ListClientDocumentVersionsForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientDocumentVersionDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "Upload New Document Version",
        "description": "Replaces the document's file with the uploaded one, in place on the practice's storage provider, and returns the updated document. The document keeps its code, title, category, folder, portal visibility and approval record, so links to it keep working, and the provider files the superseded content as an earlier revision reachable from the version list. Refused with a 400 for a document Sodium stores itself, or one on a platform that keeps no version history - there would be nowhere for the file being replaced to go.\n\nRequires: Update on ClientDocuments.",
        "operationId": "UploadClientDocumentVersionForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clientdocuments": {
      "get": {
        "tags": [
          "Client - Documents"
        ],
        "summary": "List Client Documents",
        "description": "Returns a paged list of client documents across all clients. Defaults to only showing documents sent for client approval (ClientApprovalStatus != None).\n\nRequires: ViewAll on ClientDocuments.",
        "operationId": "ListAllClientDocuments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientDocumentSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "documentCategoryCode",
            "in": "query",
            "description": "Filter by document category code",
            "schema": {
              "type": "string",
              "example": "engagement-letters"
            }
          },
          {
            "name": "reviewStatus",
            "in": "query",
            "description": "Filter by review status (Approved, PendingReview, Rejected)",
            "schema": {
              "enum": [
                "Approved",
                "PendingReview",
                "Rejected"
              ],
              "type": "string",
              "example": "PendingReview"
            }
          },
          {
            "name": "clientApprovalStatus",
            "in": "query",
            "description": "Filter by client approval status (None, Pending, Approved, Rejected)",
            "schema": {
              "enum": [
                "None",
                "Pending",
                "Approved",
                "Rejected"
              ],
              "type": "string",
              "example": "Pending"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "managerCode",
            "in": "query",
            "description": "Filter by client manager user code",
            "schema": {
              "type": "string",
              "example": "USR001"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter by client partner user code",
            "schema": {
              "type": "string",
              "example": "USR002"
            }
          },
          {
            "name": "taskCategoryCode",
            "in": "query",
            "description": "Filter by task category code",
            "schema": {
              "type": "string",
              "example": "CAT001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across document name and description (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "certificate"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientDocuments",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientemailrule": {
      "get": {
        "tags": [
          "Client - Email Rules"
        ],
        "summary": "List Email Rules for Client",
        "description": "Lists all Email Rules for the specified client.\n\nRequires: ViewAll on ClientEmailRules.",
        "operationId": "ListClientEmailRulesForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientEmailRuleSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across rule values — email addresses and domains (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "acme.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientEmailRuleDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientEmailRules",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Email Rules"
        ],
        "summary": "Create Email Rule for Client",
        "description": "Creates a new Email Rule for the specified client.\n\nRequires: Create on ClientEmailRules.",
        "operationId": "CreateClientEmailRuleForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientEmailRuleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientEmailRuleDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientEmailRules",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientemailrule/{code}": {
      "get": {
        "tags": [
          "Client - Email Rules"
        ],
        "summary": "Get Email Rule for Client",
        "description": "Gets a Email Rule for the specified client.\n\nRequires: ViewAll on ClientEmailRules.",
        "operationId": "GetClientEmailRuleForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientEmailRuleDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientEmailRules",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Email Rules"
        ],
        "summary": "Update Email Rule for Client",
        "description": "Updates the specified Email Rule for the specified client.\n\nRequires: Update on ClientEmailRules.",
        "operationId": "UpdateClientEmailRuleForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientEmailRuleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientEmailRuleDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientEmailRules",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Email Rules"
        ],
        "summary": "Delete Email Rule for Client",
        "description": "Deletes a Email Rule for the specified client.\n\nRequires: Delete on ClientEmailRules.",
        "operationId": "DeleteClientEmailRuleForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientEmailRules",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/emails": {
      "get": {
        "tags": [
          "Client - Emails"
        ],
        "summary": "List Emails for Client",
        "description": "Returns emails associated with this client based on its email rules. Rules containing '@' match that email address, GUIDs pin a specific message, and plain values match all emails from that domain. Searches across mailbox configurations the current user can access (owned or shared). Returns empty results if no rules are configured. Pass folderScope=Received for received mail in every folder except Sent, wherever it has been filed.\n\nRequires: ViewAll on ClientEmailRules.",
        "operationId": "GetClientEmails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "configCode",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "x-order": 400
          },
          {
            "name": "direction",
            "in": "query",
            "description": "Represents the direction of an email in the external mailbox",
            "schema": {
              "$ref": "#/components/schemas/MailboxEmailDirection"
            },
            "x-order": 400
          },
          {
            "name": "folderScope",
            "in": "query",
            "description": "A named set of folders to list mail from, resolved per mailbox. Where systemFolderType matches\none kind of system folder, a scope spans every folder that fits its rule, wherever the user\nhas filed the mail.",
            "schema": {
              "$ref": "#/components/schemas/MailboxFolderScope"
            },
            "x-order": 400
          },
          {
            "name": "folderUniqueId",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uuid"
              }
            },
            "x-order": 400
          },
          {
            "name": "systemFolderType",
            "in": "query",
            "description": "Identifies which provider-system folder a row represents.\nNone (0, the default) means the row is a user-created folder or a Gmail user label.",
            "schema": {
              "$ref": "#/components/schemas/SystemFolderType"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/MailboxConversationSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxThreadSummaryDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientEmailRules",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/sending-mailbox": {
      "get": {
        "tags": [
          "Client - Emails"
        ],
        "summary": "Get Client Sending Mailbox",
        "description": "Returns the mailbox an email the caller sends to this client now would go from, by the practice's client email sender rule, and whether the practice lets the caller choose another. Send screens (an HMRC authorisation request, a proposal) start their Send from on it.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetClientSendingMailbox",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientSendingMailbox"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientlink": {
      "get": {
        "tags": [
          "Client - Links"
        ],
        "summary": "List Links for Client",
        "description": "Lists all Links for the specified client.\n\nRequires: ViewAll on Clients.",
        "operationId": "ListClientLinksForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientLinkSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientLinkDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Links"
        ],
        "summary": "Create Link for Client",
        "description": "Creates a new Link for the specified client.\n\nRequires: Create on Clients.",
        "operationId": "CreateClientLinkForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientLinkRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientLinkDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientlink/{code}": {
      "get": {
        "tags": [
          "Client - Links"
        ],
        "summary": "Get Link for Client",
        "description": "Gets a Link for the specified client.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetClientLinkForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientLinkDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Links"
        ],
        "summary": "Update Link for Client",
        "description": "Updates the specified Link for the specified client.\n\nRequires: Update on Clients.",
        "operationId": "UpdateClientLinkForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientLinkRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientLinkDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Links"
        ],
        "summary": "Delete Link for Client",
        "description": "Deletes a Link for the specified client.\n\nRequires: Delete on Clients.",
        "operationId": "DeleteClientLinkForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/meetingnote": {
      "get": {
        "tags": [
          "Client - Meeting Notes"
        ],
        "summary": "List Meeting Notes for Client",
        "description": "Lists all Meeting Notes for the specified client.\n\nRequires: ViewAll on Clients.",
        "operationId": "ListMeetingNotesForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/MeetingNoteSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "medium",
            "in": "query",
            "description": "Only meetings that took place this way: InPerson, Video or Phone",
            "schema": {
              "enum": [
                "InPerson",
                "Video",
                "Phone"
              ],
              "type": "string",
              "example": "Phone"
            }
          },
          {
            "name": "startFrom",
            "in": "query",
            "description": "Only meetings that started at or after this time (UTC)",
            "schema": {
              "type": "string",
              "example": "2026-10-01T00:00:00Z"
            }
          },
          {
            "name": "startTo",
            "in": "query",
            "description": "Only meetings that started at or before this time (UTC)",
            "schema": {
              "type": "string",
              "example": "2026-10-31T23:59:59Z"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across the title and summary (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "missed call"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeetingNoteDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Meeting Notes"
        ],
        "summary": "Create Meeting Note for Client",
        "description": "Creates a new Meeting Note for the specified client.\n\nRequires: Create on Clients.",
        "operationId": "CreateMeetingNoteForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMeetingNoteRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeetingNoteDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/meetingnote/{code}": {
      "get": {
        "tags": [
          "Client - Meeting Notes"
        ],
        "summary": "Get Meeting Note for Client",
        "description": "Gets a Meeting Note for the specified client.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetMeetingNoteForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeetingNoteDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Meeting Notes"
        ],
        "summary": "Update Meeting Note for Client",
        "description": "Updates the specified Meeting Note for the specified client.\n\nRequires: Update on Clients.",
        "operationId": "UpdateMeetingNoteForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMeetingNoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeetingNoteDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Meeting Notes"
        ],
        "summary": "Delete Meeting Note for Client",
        "description": "Deletes a Meeting Note for the specified client.\n\nRequires: Delete on Clients.",
        "operationId": "DeleteMeetingNoteForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/adjustable-summaries/{taxYear}": {
      "get": {
        "tags": [
          "Client - MTD Adjustable Summaries"
        ],
        "summary": "List Adjustable Summaries",
        "description": "Returns the adjustable summaries HMRC hold for the client's income sources in a tax year, newest first within each source. An empty list is the normal state until a summary is generated, not an error.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "ListMtdAdjustableSummaries",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MtdAdjustableSummaryDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/adjustable-summaries/{calculationId}/{taxYear}/detail": {
      "get": {
        "tags": [
          "Client - MTD Adjustable Summaries"
        ],
        "summary": "Get Adjustable Summary",
        "description": "Returns one summary in full: the figures as submitted, any adjustments made to them, and the adjusted result. Whether the summary is still adjustable decides what the practice can do next — HMRC accept adjustments only once per summary.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdAdjustableSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "calculationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "incomeSourceType",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MtdIncomeSourceType"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdAdjustableSummaryDetailDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/adjustable-summaries/trigger": {
      "post": {
        "tags": [
          "Client - MTD Adjustable Summaries"
        ],
        "summary": "Trigger Adjustable Summary",
        "description": "Asks HMRC to generate a new adjustable summary for an income source and accounting period, returning its identifier. The period must have ended. This is also how a mistaken adjustment is corrected: a summary accepts adjustments once, so a correction is a fresh summary rather than a second attempt at the old one.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "TriggerMtdAdjustableSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TriggerMtdAdjustableSummaryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdTriggeredSummaryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/adjustable-summaries/{calculationId}/adjust": {
      "post": {
        "tags": [
          "Client - MTD Adjustable Summaries"
        ],
        "summary": "Submit Accounting Adjustments",
        "description": "Submits accounting adjustments against one summary. The figures are amounts to add or subtract from what HMRC summarised, not the figures they should become. HMRC accept adjustments once per summary, so this cannot be edited afterwards — a correction means triggering a fresh summary. Where nothing needs changing, declare no adjustments instead of sending zeroes.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SubmitMtdBsasAdjustments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "calculationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitMtdBsasAdjustmentsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/annual-submissions/{businessId}/{taxYear}": {
      "get": {
        "tags": [
          "Client - MTD Annual Submissions"
        ],
        "summary": "Get Annual Submission",
        "description": "Returns the year-end submission HMRC currently holds for one income source and tax year, whichever software sent it, together with who last sent or deleted it from Sodium. Nothing held is the normal state before the first year-end submission, not an error — and a held submission with no Sodium action against it means another vendor filed it.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdAnnualSubmission",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "incomeSourceType",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MtdIncomeSourceType"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdAnnualSubmissionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - MTD Annual Submissions"
        ],
        "summary": "Save Annual Submission",
        "description": "Sends the year-end values for one income source and tax year to HMRC. This is a full replacement of what HMRC holds — anything omitted is cleared — so the request must carry every value that should survive, not only what changed. Clearing the year is a delete rather than an empty save: an all-empty request is refused.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdAnnualSubmission",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdAnnualSubmissionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Annual Submissions"
        ],
        "summary": "Delete Annual Submission",
        "description": "Deletes the year-end submission HMRC holds for one income source and tax year, removing the adjustments and allowances from their computation. Who deleted it is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdAnnualSubmission",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "incomeSourceType",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MtdIncomeSourceType"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/capital-gains/{taxYear}": {
      "put": {
        "tags": [
          "Client - MTD Capital Gains"
        ],
        "summary": "Save Other Capital Gains",
        "description": "Sends the year's capital gains other than UK residential property to HMRC. This is a full replacement — every disposal that should survive must be in the request, so editing one means sending them all back; dropping the others deletes them. Clearing the year is a delete rather than an empty save.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdOtherCapitalGains",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdOtherCapitalGainsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Capital Gains"
        ],
        "summary": "Delete Other Capital Gains",
        "description": "Clears the capital gains HMRC hold for the tax year other than UK residential property. Residential disposals are untouched. Who deleted them is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdOtherCapitalGains",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/capital-gains/{taxYear}/residential": {
      "put": {
        "tags": [
          "Client - MTD Capital Gains"
        ],
        "summary": "Save Residential Disposals",
        "description": "Sends the year's UK residential property disposals to HMRC — a full replacement of the list, so every disposal that should survive must be present. A request with no disposals is refused: clearing the year is a delete rather than an empty save. Reporting here does not discharge the in-year payment-on-account return.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdCgtResidentialDisposals",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdCgtResidentialDisposalsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Capital Gains"
        ],
        "summary": "Delete Residential Disposals",
        "description": "Clears the UK residential property disposals HMRC hold for the tax year. Other gains are untouched. Who deleted them is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdCgtResidentialDisposals",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/capital-gains/{taxYear}/residential-ppd": {
      "get": {
        "tags": [
          "Client - MTD Capital Gains"
        ],
        "summary": "Get PPD Disposals",
        "description": "Returns the residential property disposals HMRC hold for the tax year from their own 'Report and pay Capital Gains Tax on UK property' service, with the latest figures against each: HMRC's own, or an override sent from here.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdCgtPpdOverrides",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdCgtPpdOverridesDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - MTD Capital Gains"
        ],
        "summary": "Save PPD Overrides",
        "description": "Sends the year's overrides to residential property disposals HMRC already hold from their PPD service. A full replacement of the overrides, accepted by HMRC only after the tax year has ended. Each override names the return it replaces. A request with no overrides is refused: clearing them is a delete rather than an empty save.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdCgtPpdOverrides",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdCgtPpdOverridesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Capital Gains"
        ],
        "summary": "Delete PPD Overrides",
        "description": "Clears the year's PPD overrides at HMRC, leaving HMRC's own figures for those disposals in force. Who deleted them is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdCgtPpdOverrides",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/dividends/{taxYear}": {
      "put": {
        "tags": [
          "Client - MTD Dividends"
        ],
        "summary": "Save Dividends Income",
        "description": "Sends the year's foreign and special dividends to HMRC. This is a full replacement of what HMRC hold — anything omitted is cleared — so the request must carry every value that should survive, not only what changed. Clearing the year is a delete rather than an empty save.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdDividendsIncome",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdDividendsIncomeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Dividends"
        ],
        "summary": "Delete Dividends Income",
        "description": "Clears the foreign and special dividends HMRC hold for the tax year. Who deleted them is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdDividendsIncome",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/dividends/{taxYear}/uk": {
      "put": {
        "tags": [
          "Client - MTD Dividends"
        ],
        "summary": "Save UK Dividends",
        "description": "Sends the year's plain UK dividends to HMRC — a full replacement of the pair. Omitting one of the two clears it, so send both whenever both should stand. A request with neither is refused: clearing the year is a delete rather than an empty save.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdUkDividends",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdUkDividendsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Dividends"
        ],
        "summary": "Delete UK Dividends",
        "description": "Clears the plain UK dividends HMRC hold for the tax year.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdUkDividends",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/dividends/{taxYear}/directorships/{employmentId}": {
      "get": {
        "tags": [
          "Client - MTD Dividends"
        ],
        "summary": "Get Directorship Dividend",
        "description": "Returns the additional directorship and dividend information HMRC hold against one of the client's employments. HMRC require this from 2025-26 where the client is a director of a close company, which is why it hangs off an employment rather than the tax year alone.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdDirectorshipDividend",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdDirectorshipDividendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - MTD Dividends"
        ],
        "summary": "Save Directorship Dividend",
        "description": "Sends the directorship and dividend information for one employment — a full replacement of what HMRC hold against it.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdDirectorshipDividend",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdDirectorshipDividendRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Dividends"
        ],
        "summary": "Delete Directorship Dividend",
        "description": "Clears the directorship and dividend information HMRC hold against one employment.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdDirectorshipDividend",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/employments/{taxYear}": {
      "post": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Add Custom Employment",
        "description": "Adds an employment HMRC do not already hold from the employer's own submissions, and returns the identifier HMRC issue. Only for employments HMRC are missing — adding one that duplicates an HMRC-held employment double-counts the income. To take an HMRC-held employment out of the calculation, ignore it rather than replacing it.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "AddMtdCustomEmployment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddMtdCustomEmploymentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdEmploymentCreatedDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/employments/{taxYear}/income/non-paye": {
      "put": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Save Non-PAYE Employment Income",
        "description": "Sends the year's non-PAYE employment income to HMRC — a full replacement of what they hold. Clearing the year is a delete rather than an empty save.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdNonPayeEmployment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdNonPayeEmploymentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Delete Non-PAYE Employment Income",
        "description": "Clears the non-PAYE employment income HMRC hold for the tax year.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdNonPayeEmployment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/employments/{taxYear}/income/other": {
      "put": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Save Other Employment Income",
        "description": "Sends the year's share schemes, lump sums and employment deductions to HMRC. A full replacement — every entry that should survive must be in the request, so editing one means sending them all back. Clearing the year is a delete rather than an empty save.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdOtherEmploymentIncome",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdOtherEmploymentIncomeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Delete Other Employment Income",
        "description": "Clears the other employment income HMRC hold for the tax year.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdOtherEmploymentIncome",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/employments/{taxYear}/{employmentId}": {
      "get": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Get Employment",
        "description": "Returns one employment in full: HMRC's record of it and the financial details currently held against it. HMRC keep the employer's figures and any provided here side by side; the details returned are whichever the year's tax calculation runs on, and say which source they came from.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdEmployment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdEmploymentDetailDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Amend Custom Employment",
        "description": "Amends a custom employment — a full replacement of its record, so every value that should survive must be present. HMRC refuse this for an employment they hold themselves: that is the employer's record, and ignoring it is the way to take it out of the calculation.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "AmendMtdCustomEmployment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AmendMtdCustomEmploymentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Delete Custom Employment",
        "description": "Deletes a custom employment at HMRC. Only custom employments can be deleted — an HMRC-held one is the employer's record, and ignoring it is the way to exclude it.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdCustomEmployment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/employments/{taxYear}/{employmentId}/ignore": {
      "post": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Ignore Employment",
        "description": "Marks an HMRC-held employment as ignored, leaving it out of the year's tax calculation. This is how a duplicated or wrong employment from an employer's submissions is dealt with: the record stays at HMRC — it is the employer's, not ours to delete — but stops counting. Not available for custom employments, which are deleted instead.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "IgnoreMtdEmployment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Unignore Employment",
        "description": "Removes the ignored marker from an HMRC-held employment, putting it back into the year's tax calculation.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "UnignoreMtdEmployment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/employments/{taxYear}/{employmentId}/financial-details": {
      "put": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Save Employment Financial Details",
        "description": "Sends the pay, tax, benefits in kind and deductions for one employment. A full replacement of the figures provided from this side — not of the employer's, which HMRC keep alongside. The figures sent here take precedence for the year, which is why deleting them restores the employer's rather than leaving nothing.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdEmploymentFinancialDetails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdEmploymentFinancialDetailsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Delete Employment Financial Details",
        "description": "Deletes the financial details provided from this side for one employment, leaving whatever the employer submitted to stand.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdEmploymentFinancialDetails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/employments/{taxYear}/{employmentId}/student-loan-benefit": {
      "get": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Get Student Loan Benefit",
        "description": "Returns the payrolled benefits affecting student loan repayments HMRC hold against one of the client's employments. HMRC hold this from 2025-26.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdStudentLoanBenefit",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdStudentLoanBenefitDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Save Student Loan Benefit",
        "description": "Sends the payrolled benefits that affect student loan repayments for one employment. A full replacement of the one figure at HMRC.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdStudentLoanBenefit",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdStudentLoanBenefitRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Employments"
        ],
        "summary": "Delete Student Loan Benefit",
        "description": "Deletes the student loan benefits in kind HMRC hold for one employment. Who deleted them is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdStudentLoanBenefit",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "employmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/foreign-properties/{businessId}/{taxYear}": {
      "get": {
        "tags": [
          "Client - MTD Foreign Properties"
        ],
        "summary": "List Foreign Properties",
        "description": "Returns the foreign properties HMRC hold registered against an income source for the tax year, each with the identifier every filing for that let names it by. An empty list means none are registered yet, not a failure. For 2025-26 and earlier HMRC keep no register — the response says so through isKeyedByProperty and lists nothing.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "ListMtdForeignProperties",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdForeignPropertiesDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - MTD Foreign Properties"
        ],
        "summary": "Register Foreign Property",
        "description": "Registers one foreign property with HMRC and returns the identifier they issue. Each call creates a new property, so this is not safe to repeat: a duplicate leaves the client with two identical lets and figures split between them. The name must be unique among the client's properties in that country.\n\nRequires: Create on MakingTaxDigitalIncomeTax.",
        "operationId": "RegisterMtdForeignProperty",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterMtdForeignPropertyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdForeignPropertyCreatedDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/foreign-properties/property/{propertyId}/{taxYear}": {
      "put": {
        "tags": [
          "Client - MTD Foreign Properties"
        ],
        "summary": "Update Foreign Property",
        "description": "Renames a registered foreign property, or records that it stopped producing income. Keyed by the property id alone — HMRC's own path shape. The country cannot be changed: a property registered against the wrong one is ended as added in error and registered again, because figures already filed name it by its identifier.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "UpdateMtdForeignProperty",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "propertyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMtdForeignPropertyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/businesses/{businessId}": {
      "get": {
        "tags": [
          "Client - MTD Income Sources"
        ],
        "summary": "Get Income Source",
        "description": "Returns one income source in detail: its trading name, commencement and cessation dates, the accounting periods HMRC hold, and the quarterly reporting choice. HMRC only return a quarterly period type when the client actively elected one, so its absence means standard quarters by default rather than unknown.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdBusinessDetails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdBusinessDetailsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/businesses/{businessId}/{taxYear}/accounting-type": {
      "put": {
        "tags": [
          "Client - MTD Income Sources"
        ],
        "summary": "Set Accounting Basis",
        "description": "Sets the accounting basis — cash or accruals — for one income source and tax year. HMRC accept this during the year and up to the tax return; after that the year's basis is fixed and HMRC refuse the change. It changes how the year's figures are computed, so it belongs before the figures are prepared.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SetMtdAccountingType",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetMtdAccountingTypeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/businesses/{businessId}/{taxYear}/periods-of-account": {
      "put": {
        "tags": [
          "Client - MTD Income Sources"
        ],
        "summary": "Set Periods Of Account",
        "description": "Declares whether a self-employment income source draws its accounts to periods other than the tax year, and if so what those periods are — a full replacement of the year's declaration, required before the tax return. The two halves must agree: periods are required when the business has them and must be absent when it does not.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SetMtdPeriodsOfAccount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetMtdPeriodsOfAccountRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/businesses/{businessId}/{taxYear}/late-accounting-date-rule": {
      "post": {
        "tags": [
          "Client - MTD Income Sources"
        ],
        "summary": "Disapply Late Accounting Date Rule",
        "description": "Elects to disapply the automatic late accounting date rule for the tax year, so the 1–5 April profits are apportioned and reported separately rather than folded into the year. Only a business whose accounting date falls between 31 March and 4 April is eligible. HMRC accept the election only once the year has ended, and it then stands for five years.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "DisapplyMtdLateAccountingDateRule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Income Sources"
        ],
        "summary": "Withdraw Late Accounting Date Rule Election",
        "description": "Withdraws a disapplication election, putting the income source back on the automatic late accounting date rule. HMRC accept this only once the year has ended and the existing election has expired — it is not an undo for an election made by mistake.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "WithdrawMtdLateAccountingDateRule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/itsa-status/{taxYear}": {
      "get": {
        "tags": [
          "Client - MTD ITSA Status"
        ],
        "summary": "Get Client ITSA Status",
        "description": "The client's Income Tax Self Assessment status with HMRC for the tax year (2026-27 form), and later years with futureYears: whether they are mandated into MTD, volunteered, exempt, on annual filing or dormant. 400 when the client has no National Insurance number or HMRC refuse the request.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdItsaStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "futureYears",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItsaStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/losses/{taxYear}": {
      "get": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Get Losses",
        "description": "Returns the losses and loss claims HMRC hold for the tax year, in whichever of their two shapes that year uses — isRecordBased says which. Empty lists mean HMRC hold none, which is an answer rather than a failure. From 2026-27 the year is one document per income source, so businessId is required to read anything.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdLosses",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdLossesDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/losses/brought-forward/{taxYear}": {
      "post": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Create Brought Forward Loss",
        "description": "Records a loss carried forward from a year before Making Tax Digital and returns HMRC's identifier for it. Tax years to 2025-26 only. Not safe to repeat: a second call either creates a duplicate loss or is refused as one. The year the loss arose in must have ended, and the claim types available later depend on the type of loss chosen here.\n\nRequires: Create on MakingTaxDigitalIncomeTax.",
        "operationId": "CreateMtdBroughtForwardLoss",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMtdBroughtForwardLossRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdLossCreatedDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/losses/brought-forward/{lossId}/{taxYear}/amount": {
      "post": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Amend Brought Forward Loss",
        "description": "Changes a brought forward loss's amount — the only part HMRC let you change — and returns the loss as they now hold it. A POST rather than a PUT because HMRC refuse an amend that changes nothing, so this must not be sent with unchanged values.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "AmendMtdBroughtForwardLoss",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "lossId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AmendMtdBroughtForwardLossRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdBroughtForwardLossDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/losses/brought-forward/{lossId}/{taxYear}": {
      "delete": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Delete Brought Forward Loss",
        "description": "Deletes a brought forward loss. HMRC block this once the loss has been used in a final declaration — the way to take the figure out of the computation then is to amend the amount to zero, which leaves the record in place.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdBroughtForwardLoss",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "lossId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/losses/claims": {
      "post": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Create Loss Claim",
        "description": "Claims a loss and returns HMRC's identifier for the claim. Tax years to 2025-26 only, and HMRC accept nothing until the income source's accounting period has ended. The claim type must be legal for the type of loss: a sole trade is carried forward or set sideways, a property business takes the other three.\n\nRequires: Create on MakingTaxDigitalIncomeTax.",
        "operationId": "CreateMtdLossClaim",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMtdLossClaimRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdLossCreatedDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/losses/claims/{claimId}/{taxYear}/type": {
      "post": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Amend Loss Claim Type",
        "description": "Changes a loss claim's type — the only part of a claim HMRC let you amend — and returns the claim as they now hold it. A POST for the same reason as the loss amend.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "AmendMtdLossClaimType",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "claimId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AmendMtdLossClaimTypeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdLossClaimDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/losses/claims/{claimId}/{taxYear}": {
      "delete": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Delete Loss Claim",
        "description": "Deletes a loss claim. Who deleted it is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdLossClaim",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "claimId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/losses/claims/{taxYear}/order": {
      "put": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Amend Loss Claims Order",
        "description": "Replaces the order in which HMRC apply the year's carry-sideways loss claims. A full replacement: every carry-sideways claim for the year must be in the list, positioned from 1 upwards with no gaps. Sending a subset is refused rather than merged.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "AmendMtdLossClaimsOrder",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AmendMtdLossClaimsOrderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/losses/document/{businessId}/{taxYear}": {
      "put": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Save Losses And Claims",
        "description": "Sends one income source's whole losses-and-claims position for a tax year from 2026-27 onwards. A full replacement of what HMRC hold — anything omitted is cleared — so the request must carry every figure that should survive. HMRC accept it only after the tax year has ended, and carry-back claims must be sent before the tax return is filed.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdLossesAndClaims",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdLossesAndClaimsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Losses"
        ],
        "summary": "Delete Losses And Claims",
        "description": "Clears the losses and claims HMRC hold for one income source and tax year (2026-27 onwards). Clearing is a delete rather than an empty save. Who deleted it is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdLossesAndClaims",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/nominal-mappings": {
      "get": {
        "tags": [
          "Client - MTD Nominal Mappings"
        ],
        "summary": "List Books Mappings",
        "description": "Returns whether this client's books can feed their quarterly updates, and which of their MTD income sources already have a confirmed mapping. Not being linked to any accounting software, and being on a platform the books pull has not reached yet, are both normal answers rather than errors.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "ListMtdNominalMappings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdNominalMappingStatusDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/nominal-mappings/{businessId}": {
      "get": {
        "tags": [
          "Client - MTD Nominal Mappings"
        ],
        "summary": "Get Books Mapping",
        "description": "Returns which nominal accounts feed each figure of one income source's quarterly update. Before anything is confirmed this is a SUGGESTION — the platform's shipped catalogue crossed with the client's live chart of accounts, flagged as such — and confirming it with a PUT is what makes it the practice's own. Ambiguous accounts are left blank on purpose: a wrong guess files a figure into the wrong HMRC box.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdNominalMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "incomeSourceType",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MtdIncomeSourceType"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdNominalMappingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - MTD Nominal Mappings"
        ],
        "summary": "Save Books Mapping",
        "description": "Confirms which nominal accounts feed each figure, replacing any previous mapping for this income source. Entries that arrive without the platform's account id have one resolved from the live chart, so the mapping survives an account being re-coded in the books later. Consolidated expenses and the expense breakdown cannot both be mapped — HMRC accept one or the other.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdNominalMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdNominalMappingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdNominalMappingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Nominal Mappings"
        ],
        "summary": "Delete Books Mapping",
        "description": "Forgets the mapping for one income source. The next read suggests again from the platform's catalogue, which is the way back to a clean start when a chart of accounts has changed beyond patching.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdNominalMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/nominal-mappings/{businessId}/figures": {
      "get": {
        "tags": [
          "Client - MTD Nominal Mappings"
        ],
        "summary": "Pull Figures From Books",
        "description": "Reads the cumulative period's figures from the client's connected books and maps them into the boxes of a quarterly update, for review. Nothing is saved and nothing reaches HMRC: the figures go back to the quarterly-update form, where the practice checks and edits them before the normal save and submit path. Accounts with figures that the mapping says nothing about come back as a list to answer rather than being dropped, and disallowable expenses are never filled in — a chart of accounts has no concept of them.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdMappedFigures",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "incomeSourceType",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MtdIncomeSourceType"
            },
            "x-order": 400
          },
          {
            "name": "periodEndDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "periodStartDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdMappedFiguresDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/quarterly-updates": {
      "get": {
        "tags": [
          "Client - MTD Quarterly Updates"
        ],
        "summary": "List Quarterly Updates",
        "description": "Returns the quarterly updates the practice has prepared or sent for this client — every tax year, or one when a tax year is given. Figures are cumulative from the start of the tax year, so there is at most one live record per income source per year — earlier ones are marked superseded.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "ListMtdQuarterlyUpdates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MtdQuarterlySubmissionDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - MTD Quarterly Updates"
        ],
        "summary": "Save Quarterly Update",
        "description": "Saves the cumulative year-to-date figures for one income source, creating the draft on first save and replacing the figures on later saves. Editing figures that have already been sent starts a correction: the record returns to draft and the previous declaration is cleared. Nothing is sent to HMRC by this call.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdQuarterlyUpdate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdQuarterlySubmissionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdQuarterlySubmissionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/quarterly-updates/{code}/submit": {
      "post": {
        "tags": [
          "Client - MTD Quarterly Updates"
        ],
        "summary": "Submit Quarterly Update",
        "description": "Sends the prepared figures to HMRC, recording who declared them correct. HMRC's obligation status can take up to an hour to catch up, so the obligation may still show as open immediately afterwards. If the outcome is unknown — a timeout, or no response — the update is left in a submitting state to be resolved by reading the position back from HMRC, never by sending again.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SubmitMtdQuarterlyUpdate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitMtdQuarterlyUpdateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdQuarterlySubmissionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/quarterly-updates/{code}/calculation": {
      "get": {
        "tags": [
          "Client - MTD Quarterly Updates"
        ],
        "summary": "Get Tax Calculation",
        "description": "Returns HMRC's tax calculation for the year, triggered when this update was accepted — the client's estimated position with the new figures in. HMRC calculates asynchronously, so shortly after submission the calculation may not be complete yet; an incomplete result is normal and worth asking for again, while a calculation with errors is HMRC's final answer for those figures.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdCalculation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdTaxCalculationDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/quarterly-updates/held/{businessId}/{taxYear}": {
      "get": {
        "tags": [
          "Client - MTD Quarterly Updates"
        ],
        "summary": "Get HMRC Held Position",
        "description": "Returns the cumulative year-to-date position HMRC currently holds for one income source and tax year, whichever software filed it. This is how a quarter filed elsewhere becomes visible, and what a new update is seeded from so figures are edited forward rather than retyped. Nothing held is the normal state before the year's first submission, not an error.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdHeldPosition",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "incomeSourceType",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MtdIncomeSourceType"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdHeldPositionDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/quarterly-updates/period-type/{businessId}/{taxYear}": {
      "put": {
        "tags": [
          "Client - MTD Quarterly Updates"
        ],
        "summary": "Set Quarterly Period Type",
        "description": "Elects standard (6 April) or calendar (1 April) quarterly reporting periods for one of the client's income sources and a tax year. The deadlines are the same either way — only the period boundaries move. The election must be made before the tax year's first quarterly update: it locks the moment one is submitted, until the next year.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SetMtdQuarterlyPeriodType",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetMtdQuarterlyPeriodTypeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdPeriodTypeReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/quarterly-updates/{code}/reconcile": {
      "post": {
        "tags": [
          "Client - MTD Quarterly Updates"
        ],
        "summary": "Reconcile Quarterly Update",
        "description": "Asks HMRC what they actually hold for this income source and tax year, and settles an update whose outcome is unknown. A submission that timed out may or may not have reached HMRC, and the answer is never to resend a filing they may already hold. If HMRC holds figures covering the period, the update is marked as submitted; if they hold nothing, it returns to draft so it can be sent again deliberately.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "ReconcileMtdQuarterlyUpdate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdQuarterlySubmissionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/reliefs/{taxYear}/investment": {
      "put": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Save Investment Reliefs",
        "description": "Sends the year's venture capital trust, EIS, SEIS and community investment subscriptions to HMRC. A full replacement — every subscription that should survive must be in the request, so editing one means sending them all back. Clearing the year is a delete rather than an empty save.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdInvestmentReliefs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdInvestmentReliefsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Delete Investment Reliefs",
        "description": "Clears the investment reliefs HMRC hold for the tax year. The other reliefs are untouched. Who deleted them is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdInvestmentReliefs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/reliefs/{taxYear}/other": {
      "put": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Save Other Reliefs",
        "description": "Sends the year's loan interest, payroll giving, maintenance payments, post-cessation losses and annual payments to HMRC. A full replacement — every entry that should survive must be in the request.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdOtherReliefs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdOtherReliefsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Delete Other Reliefs",
        "description": "Clears the other reliefs HMRC hold for the tax year.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdOtherReliefs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/reliefs/{taxYear}/foreign": {
      "put": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Save Foreign Reliefs",
        "description": "Sends the year's foreign tax credit relief and the foreign tax paid without it claimed to HMRC. A full replacement of what HMRC hold.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdForeignReliefs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdForeignReliefsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Delete Foreign Reliefs",
        "description": "Clears the foreign tax reliefs HMRC hold for the tax year.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdForeignReliefs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/reliefs/{taxYear}/pensions": {
      "put": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Save Pensions Reliefs",
        "description": "Sends the year's pension contribution reliefs to HMRC. A full replacement of all five figures, so send every one that should stand — an omitted figure is cleared.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdPensionsReliefs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdPensionsReliefsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Delete Pensions Reliefs",
        "description": "Clears the pension contribution reliefs HMRC hold for the tax year.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdPensionsReliefs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/reliefs/{taxYear}/charitable-giving": {
      "put": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Save Charitable Giving",
        "description": "Sends the year's gift aid payments and gifts of shares, securities, land and buildings to HMRC. A full replacement of both halves — send them together whenever both should stand.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdCharitableGiving",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdCharitableGivingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Reliefs"
        ],
        "summary": "Delete Charitable Giving",
        "description": "Clears the charitable giving reliefs HMRC hold for the tax year.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdCharitableGiving",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/savings/accounts": {
      "post": {
        "tags": [
          "Client - MTD Savings"
        ],
        "summary": "Add Savings Account",
        "description": "Registers a UK savings account with HMRC and returns the identifier they issue. Accounts are registered once rather than per tax year, and the name must be unique for the client. HMRC provide no way to delete an account once registered.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "AddMtdSavingsAccount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddMtdSavingsAccountRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSavingsAccountCreatedDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/savings/accounts/{savingsAccountId}/name": {
      "put": {
        "tags": [
          "Client - MTD Savings"
        ],
        "summary": "Rename Savings Account",
        "description": "Renames a savings account at HMRC. The account keeps its identifier and every year's interest reported against it — this is not a way to replace an account.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "RenameMtdSavingsAccount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "savingsAccountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenameMtdSavingsAccountRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/savings/accounts/{savingsAccountId}/{taxYear}": {
      "put": {
        "tags": [
          "Client - MTD Savings"
        ],
        "summary": "Save Savings Account Interest",
        "description": "Sends one savings account's interest for the tax year to HMRC — a full replacement of the taxed/untaxed pair. Omitting one of the two clears it, so send both whenever both should stand. HMRC offer no delete here: to report no interest for the year, send zero.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdSavingsAccountInterest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "savingsAccountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdSavingsAccountInterestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/savings/other/{taxYear}": {
      "put": {
        "tags": [
          "Client - MTD Savings"
        ],
        "summary": "Save Other Savings Income",
        "description": "Sends the year's securities and foreign interest to HMRC. This is a full replacement of what HMRC hold — anything omitted is cleared — so the request must carry every value that should survive, not only what changed. Clearing the year is a delete rather than an empty save.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdOtherSavings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdOtherSavingsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Savings"
        ],
        "summary": "Delete Other Savings Income",
        "description": "Clears the securities and foreign interest HMRC hold for the tax year. Named accounts are untouched. Who deleted it is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdOtherSavings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/tax-liability-adjustments/{taxYear}": {
      "get": {
        "tags": [
          "Client - MTD Tax Liability Adjustments"
        ],
        "summary": "Get Tax Liability Adjustments",
        "description": "Returns the tax liability adjustments HMRC hold for the tax year, whichever software sent them, with who last sent or deleted them from Sodium. isHeld is false when HMRC hold none. Tax years before 2026-27 are refused rather than answered empty, because those years have no adjustments to make.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdTaxLiabilityAdjustments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdTaxLiabilityAdjustmentsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - MTD Tax Liability Adjustments"
        ],
        "summary": "Save Tax Liability Adjustments",
        "description": "Sends the year's tax liability adjustments to HMRC. A full replacement of what they hold — anything omitted is cleared — and every figure is a positive amount. HMRC accept it only after the tax year has ended. The carry-back figures are what a carry-back loss claim is worth against this year's bill, so the claim itself must be sent first.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdTaxLiabilityAdjustments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdTaxLiabilityAdjustmentsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdSubmissionReceiptDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - MTD Tax Liability Adjustments"
        ],
        "summary": "Delete Tax Liability Adjustments",
        "description": "Clears the tax liability adjustments HMRC hold for the tax year. Clearing is a delete rather than an empty save. Who deleted them is recorded.\n\nRequires: Delete on MakingTaxDigitalIncomeTax.",
        "operationId": "DeleteMtdTaxLiabilityAdjustments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/tax-return/{taxYear}": {
      "get": {
        "tags": [
          "Client - MTD Tax Return"
        ],
        "summary": "Review Tax Return",
        "description": "Everything that has to be right before a client's tax return is sent: every income source's obligations, reporting setup, held position, year-end submission and adjustable summaries; all their other income; losses; liability adjustments where the year has them; HMRC's calculation; and the declaration with whatever is standing in the way. This is thirty or more HMRC requests behind one call, so it is slow the first time a year is opened and fast afterwards. Pass refresh=true to ask HMRC again rather than reuse cached answers — only ever from an explicit action by the user. Anything named in unavailableParts could not be read from HMRC; it never means HMRC hold nothing.\n\nRequires: ViewAll on MakingTaxDigitalTaxReturn.",
        "operationId": "GetMtdTaxReturn",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "refresh",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdTaxReturnDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalTaxReturn",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/tax-return/{taxYear}/calculation": {
      "post": {
        "tags": [
          "Client - MTD Tax Return"
        ],
        "summary": "Trigger Tax Return Calculation",
        "description": "Asks HMRC to run the calculation a tax return declares: as an intent to finalise for the return itself, or as an intent to amend for a change to a return already sent. The in-year estimates the quarterly updates produce are never candidates, so nothing can be sent for a year until this has been run. HMRC work the calculation out after answering — read the review again a few seconds later for its figures. Each call creates a new calculation, and the review declares the newest.\n\nRequires: Update on MakingTaxDigitalTaxReturn.",
        "operationId": "TriggerMtdTaxReturnCalculation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TriggerMtdTaxReturnCalculationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdTaxReturnCalculationDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalTaxReturn",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/tax-return/{taxYear}/submit": {
      "post": {
        "tags": [
          "Client - MTD Tax Return"
        ],
        "summary": "Send Tax Return",
        "description": "Sends the client's tax return to HMRC against the calculation named in the request. Refused unless the declaration has been read and agreed, and refused when the declaration wording has changed since it was displayed. This filing is not idempotent: HMRC create something that cannot be re-stated, so a submission whose outcome is unknown stays in flight and is settled by reconciling it — never by sending again. HMRC take up to an hour to show the year as fulfilled, so say 'sent' rather than 'filed' until they do. Costs one filing credit, reserved before the call and released if it definitively did not land.\n\nRequires: Update on MakingTaxDigitalTaxReturn.",
        "operationId": "SubmitMtdTaxReturn",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitMtdTaxReturnRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdTaxReturnSubmissionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalTaxReturn",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/tax-return/{taxYear}/submissions/{submissionCode}/reconcile": {
      "post": {
        "tags": [
          "Client - MTD Tax Return"
        ],
        "summary": "Reconcile Tax Return",
        "description": "Settles a tax return whose outcome nobody knows, by reading HMRC's own record back — the only safe way out of an in-flight submission, because sending again would give HMRC two returns for one year. Refused within HMRC's first hour, when 'no record' and 'never arrived' are the same answer: that refusal is the correct result and its message says so, not a failure to retry around.\n\nRequires: Update on MakingTaxDigitalTaxReturn.",
        "operationId": "ReconcileMtdTaxReturn",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "submissionCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdTaxReturnSubmissionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalTaxReturn",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/tax-return": {
      "get": {
        "tags": [
          "Client - MTD Tax Return"
        ],
        "summary": "List Tax Returns",
        "description": "The tax returns sent for this client from Sodium, newest first, optionally filtered to one tax year. A local read with no HMRC call — a year filed by other software appears here as nothing at all, and HMRC's fulfilled obligation on the review is what says so.\n\nRequires: ViewAll on MakingTaxDigitalTaxReturn.",
        "operationId": "ListMtdTaxReturns",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MtdTaxReturnSubmissionDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalTaxReturn",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/income-sources": {
      "get": {
        "tags": [
          "Client - MTD Tax Year"
        ],
        "summary": "Get Income Sources And Deadlines",
        "description": "The client's income sources with every quarterly update deadline HMRC expects of them, their tax return deadlines, and every tax year those cover — each period carrying the tax year it is filed against. HMRC's income source list and its obligations answer different questions and are joined for you, so a source with no deadlines and a ceased source with deadlines but no listing both survive. Deliberately not scoped to a tax year: HMRC answers all of it per client, so a year-scoped call would re-fetch identical data every time the year changed on screen. Filter on the periods' taxYear.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdIncomeSources",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdIncomeSourcesDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/tax-years/{taxYear}/income-sources/{businessId}": {
      "get": {
        "tags": [
          "Client - MTD Tax Year"
        ],
        "summary": "Get One Income Source's Year Setup",
        "description": "How one income source is reporting the year: the accounting basis, the periods of account and the late accounting date rule election, with who last set each from Sodium. Periods of account and the late accounting date rule are self-employment only; supportsPeriodsOfAccount and supportsLateAccountingDateRule say whether they apply at all, so 'does not apply' is never mistaken for 'nothing declared yet'.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdIncomeSourceConfig",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "businessId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdBusinessYearConfigDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/tax-years/{taxYear}/other-income": {
      "get": {
        "tags": [
          "Client - MTD Tax Year"
        ],
        "summary": "Get Other Income For A Tax Year",
        "description": "Everything HMRC hold for the year outside the client's trading income — dividends, savings and their interest, employment income, all five reliefs and capital gains — with who last sent each from Sodium. Fourteen HMRC resources behind one read. Areas HMRC could not be asked about are named on unavailableAreas, and their values mean nothing rather than 'nothing held': the two are different answers and must not be shown alike. Nothing held across the board is the normal state for most clients, not an error.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdOtherIncome",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdOtherIncomeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/mtd/tax-years/{taxYear}/export": {
      "get": {
        "tags": [
          "Client - MTD Tax Year"
        ],
        "summary": "Export MTD Records",
        "description": "The client's whole Making Tax Digital record for the tax year as a CSV: every quarterly update prepared or sent — superseded ones included, because a corrected filing is part of the history — the year-end annual submission held for each income source, and the year's other income, reliefs and gains. Every row carries the period, the status, who prepared and submitted it, and HMRC's correlation id, which is the only evidence of an exchange MTD issues no receipt for. Parts HMRC could not answer for are written into the file as explained gaps rather than failing the export.\n\nRequires: Export on MakingTaxDigitalIncomeTax.",
        "operationId": "ExportMtdRecordsCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "taxYear",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientnote": {
      "get": {
        "tags": [
          "Client - Notes"
        ],
        "summary": "List Notes for Client",
        "description": "Lists all Notes for the specified client.\n\nRequires: ViewAll on Clients.",
        "operationId": "ListClientNotesForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientNoteSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "authorCode",
            "in": "query",
            "description": "Filter by author (user) code",
            "schema": {
              "type": "string",
              "example": "USR001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across note text (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "meeting"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Notes"
        ],
        "summary": "Create Note for Client",
        "description": "Creates a new note for the specified client. If NoteFromUserCode is not provided, it defaults to the authenticated user.\n\nRequires: Create on Clients.",
        "operationId": "CreateClientNoteForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientNoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientnote/{code}": {
      "get": {
        "tags": [
          "Client - Notes"
        ],
        "summary": "Get Note for Client",
        "description": "Gets a Note for the specified client.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetClientNoteForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Notes"
        ],
        "summary": "Update Note for Client",
        "description": "Updates the specified Note for the specified client.\n\nRequires: Update on Clients.",
        "operationId": "UpdateClientNoteForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientNoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Notes"
        ],
        "summary": "Delete Note for Client",
        "description": "Deletes a Note for the specified client.\n\nRequires: Delete on Clients.",
        "operationId": "DeleteClientNoteForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientnote/pinned": {
      "get": {
        "tags": [
          "Client - Notes"
        ],
        "summary": "Get Pinned Notes for Client",
        "description": "Gets all pinned notes for the specified client (PinnedLevel > 0), ordered by PinnedLevel descending.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetPinnedClientNotes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NoteDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/clientnote/summary": {
      "get": {
        "tags": [
          "Client - Notes"
        ],
        "summary": "Get Client Notes Summary",
        "description": "Returns the AI summary of the client's notes, with whether a note has been added, edited or deleted since it was generated. 204 when there is none.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetClientNotesSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientNotesSummaryDto"
                }
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Notes"
        ],
        "summary": "Generate Client Notes Summary",
        "description": "Sends the client's newest notes to the AI and saves its answer as the client's notes summary, replacing any there was, and returns it. Refused when the client has no notes. 502 when the AI service fails.\n\nRequires at least one of: Create on Clients or Update on Clients.",
        "operationId": "GenerateClientNotesSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientNotesSummaryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "502": {
            "description": "Bad Gateway"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "Clients",
              "permission": "Create"
            },
            {
              "entity": "Clients",
              "permission": "Update"
            }
          ]
        ]
      },
      "delete": {
        "tags": [
          "Client - Notes"
        ],
        "summary": "Delete Client Notes Summary",
        "description": "Deletes the AI summary of the client's notes, if it has one.\n\nRequires at least one of: Create on Clients or Update on Clients.",
        "operationId": "DeleteClientNotesSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "Clients",
              "permission": "Create"
            },
            {
              "entity": "Clients",
              "permission": "Update"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/open-work/role-handover/preview": {
      "post": {
        "tags": [
          "Client - Open Work"
        ],
        "summary": "Preview Role Handover",
        "description": "Counts the open tasks and unfinished workflow steps that would move to each role's new holder, without moving them. The new holder is read from the client or service as saved, so call this after the role change is saved.\n\nRequires: ViewAll on Tasks.",
        "operationId": "PreviewClientRoleHandover",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RoleHandoverRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RoleHandoverResultDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/open-work/role-handover": {
      "post": {
        "tags": [
          "Client - Open Work"
        ],
        "summary": "Apply Role Handover",
        "description": "Moves the client's open tasks and unfinished workflow steps that were assigned from each role, and still sit with the previous holder or with nobody, to the role's new holder. Returns what moved.\n\nRequires: Update on Tasks.",
        "operationId": "ApplyClientRoleHandover",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RoleHandoverRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RoleHandoverResultDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/pipelines/clientpipeline": {
      "get": {
        "tags": [
          "Client - Pipelines"
        ],
        "summary": "List Client Pipelines for Client",
        "description": "Lists all Client Pipelines for the specified client.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "ListClientPipelinesForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientPipelineSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientPipelineDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Pipelines"
        ],
        "summary": "Create Client Pipeline for Client",
        "description": "Creates a new Client Pipeline for the specified client.\n\nRequires: Create on Pipelines.",
        "operationId": "CreateClientPipelineForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientPipelineRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientPipelineDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/pipelines/clientpipeline/{code}": {
      "get": {
        "tags": [
          "Client - Pipelines"
        ],
        "summary": "Get Client Pipeline for Client",
        "description": "Gets a Client Pipeline for the specified client.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "GetClientPipelineForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientPipelineDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Pipelines"
        ],
        "summary": "Update Client Pipeline for Client",
        "description": "Updates the specified Client Pipeline for the specified client.\n\nRequires: Update on Pipelines.",
        "operationId": "UpdateClientPipelineForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientPipelineRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientPipelineDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Pipelines"
        ],
        "summary": "Delete Client Pipeline for Client",
        "description": "Deletes a Client Pipeline for the specified client.\n\nRequires: Delete on Pipelines.",
        "operationId": "DeleteClientPipelineForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/pipelines/{code}/stage": {
      "patch": {
        "tags": [
          "Client - Pipelines"
        ],
        "summary": "Update Client Pipeline Stage",
        "description": "Updates only the stage for a client pipeline card, targeted by the card's own code. Designed for kanban board drag-and-drop — avoids the overhead of a full PUT.\n\nRequires: Update on Pipelines.",
        "operationId": "UpdateClientPipelineStage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientPipelineStageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/pipelines/{code}/deal": {
      "put": {
        "tags": [
          "Client - Pipelines"
        ],
        "summary": "Update Client Pipeline Deal",
        "description": "Replaces a client pipeline card's deal (value and likelihood 0-100%), targeted by the card's own code. Both fields are sent every time; null clears one. Leaves the stage, manager and dates untouched.\n\nRequires: Update on Pipelines.",
        "operationId": "UpdateClientPipelineDeal",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientPipelineDealRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clientpipelines": {
      "get": {
        "tags": [
          "Client - Pipelines"
        ],
        "summary": "List Client Pipeline Summaries",
        "description": "Returns a paged list of client pipeline card summaries across all clients. Returns a lightweight projection designed for kanban board display. Filter by pipelineCode and stageCode to load a single kanban column.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "ListClientPipelineSummaries",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "includeTasks",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientPipelineSummarySortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "pipelineCode",
            "in": "query",
            "description": "Filter by pipeline code",
            "schema": {
              "type": "string",
              "example": "sales-pipeline"
            }
          },
          {
            "name": "stageCode",
            "in": "query",
            "description": "Filter by stage code",
            "schema": {
              "type": "string",
              "example": "new-lead"
            }
          },
          {
            "name": "taskCategoryCode",
            "in": "query",
            "description": "Filter tasks on kanban cards by task category code",
            "schema": {
              "type": "string",
              "example": "follow-up"
            }
          },
          {
            "name": "clientManagerCode",
            "in": "query",
            "description": "Filter by client manager user code",
            "schema": {
              "type": "string",
              "example": "john-smith"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter by partner user code",
            "schema": {
              "type": "string",
              "example": "jane-doe"
            }
          },
          {
            "name": "minLikelihood",
            "in": "query",
            "description": "Only cards with a likelihood (0-100) at or above this value",
            "schema": {
              "type": "integer",
              "example": "80"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across client name and code (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "acme"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientPipelineSummaryDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clientpipelines/stage-counts": {
      "get": {
        "tags": [
          "Client - Pipelines"
        ],
        "summary": "Get Client Pipeline Stage Counts",
        "description": "Returns per-stage card counts for a pipeline's kanban board, including each stage's display settings (icon, colour, sort order). One row per stage, including empty stages, in board display order. Designed for dashboard widgets — a single lightweight query instead of loading board columns. Pass clientManagerCode to scope the counts to one client manager's clients; stages with no matching cards stay in the list with a count of zero.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "GetClientPipelineStageCounts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientManagerCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "pipelineCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KanbanStageCountDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/recurring-tasks": {
      "get": {
        "tags": [
          "Client - Recurring Task Schedules"
        ],
        "summary": "List Recurring Tasks for Client",
        "description": "Returns a paged list of the recurring tasks that apply to this client. Each row's schedule is the one that applies to the client - their custom schedule when linked, else the task's default - with IsDefaultSchedule saying which.\n\nRequires: ViewAll on RecurringTasks.",
        "operationId": "ListRecurringTasksForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/RecurringTaskItemSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "isActive",
            "in": "query",
            "description": "Filter by active status (true = active only, false = inactive only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Filter by billable service code: tasks that run for the service's clients, and tasks assigned to its manager, preparer or reviewer (IsForServiceClients says which)",
            "schema": {
              "type": "string",
              "example": "ACC-001"
            }
          },
          {
            "name": "pipelineCode",
            "in": "query",
            "description": "Filter by sales pipeline code",
            "schema": {
              "type": "string",
              "example": "PIP-001"
            }
          },
          {
            "name": "categoryCode",
            "in": "query",
            "description": "Filter by task category code",
            "schema": {
              "type": "string",
              "example": "CAT-001"
            }
          },
          {
            "name": "workflowCode",
            "in": "query",
            "description": "Filter by workflow code",
            "schema": {
              "type": "string",
              "example": "WF-001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across recurring task code, name, and description (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "vat"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskItemDtoPagedResult"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/recurring-tasks/{taskCode}/schedule": {
      "get": {
        "tags": [
          "Client - Recurring Task Schedules"
        ],
        "summary": "Get Recurring Task Schedule for Client",
        "description": "Gets the non-default schedule a client is linked to on a recurring task. 404 means the client runs on the task's default schedule.\n\nRequires: ViewAll on RecurringTasks.",
        "operationId": "GetRecurringTaskScheduleForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskScheduleDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Recurring Task Schedules"
        ],
        "summary": "Assign Recurring Task Schedule for Client",
        "description": "Links a client to one of the recurring task's existing schedules. Schedules are created and managed under the task's schedule routes; reverting to the default schedule is the DELETE on this route.\n\nRequires: Update on RecurringTasks.",
        "operationId": "AssignRecurringTaskScheduleForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignClientScheduleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Recurring Task Schedules"
        ],
        "summary": "Revert Recurring Task Schedule for Client",
        "description": "Removes a client's schedule link, returning them to the recurring task's default schedule.\n\nRequires: Update on RecurringTasks.",
        "operationId": "RevertRecurringTaskScheduleForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-request-settings": {
      "get": {
        "tags": [
          "Client - Request & Chasing"
        ],
        "summary": "Get Client Request Settings",
        "description": "Returns the client request and chasing settings for the specified tenant\n\nRequires: ViewAll on ClientPortalSettings.",
        "operationId": "GetClientRequestSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientRequestSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Request & Chasing"
        ],
        "summary": "Update Client Request Settings",
        "description": "Updates the client request and chasing settings for the specified tenant\n\nRequires: Update on ClientPortalSettings.",
        "operationId": "UpdateClientRequestSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientRequestSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientRequestSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/services/clientbillableservice": {
      "get": {
        "tags": [
          "Client - Services"
        ],
        "summary": "List Client Services for Client",
        "description": "Lists all Client Services for the specified client.\n\nRequires: ViewAll on ClientBillableServices.",
        "operationId": "ListClientBillableServicesForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientBillableServiceSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillableServiceDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Client - Services"
        ],
        "summary": "Create Client Service for Client",
        "description": "Creates a new Client Service for the specified client.\n\nRequires: Create on ClientBillableServices.",
        "operationId": "CreateClientBillableServiceForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientBillableServiceRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillableServiceDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/services/clientbillableservice/{code}": {
      "get": {
        "tags": [
          "Client - Services"
        ],
        "summary": "Get Client Service for Client",
        "description": "Gets a Client Service for the specified client.\n\nRequires: ViewAll on ClientBillableServices.",
        "operationId": "GetClientBillableServiceForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillableServiceDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client - Services"
        ],
        "summary": "Update Client Service for Client",
        "description": "Updates the specified Client Service for the specified client.\n\nRequires: Update on ClientBillableServices.",
        "operationId": "UpdateClientBillableServiceForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientBillableServiceRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillableServiceDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Client - Services"
        ],
        "summary": "Delete Client Service for Client",
        "description": "Deletes a Client Service for the specified client.\n\nRequires: Delete on ClientBillableServices.",
        "operationId": "DeleteClientBillableServiceForClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/services/required-fields": {
      "get": {
        "tags": [
          "Client - Services"
        ],
        "summary": "Get Required Client Fields",
        "description": "Returns client fields that are required by recurring tasks linked to the client's active services.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetRequiredClientFields",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientCsvTargetField"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/services/{code}/stage": {
      "patch": {
        "tags": [
          "Client - Services"
        ],
        "summary": "Update Client Service Stage",
        "description": "Updates only the stage for a client billable service, targeted by the assignment's own code (a client can hold multiple instances of the same service). Designed for kanban board drag-and-drop — avoids the overhead of a full PUT.\n\nRequires: Update on ClientBillableServices.",
        "operationId": "UpdateClientBillableServiceStage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientBillableServiceStageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/services/{code}/notes": {
      "patch": {
        "tags": [
          "Client - Services"
        ],
        "summary": "Update Client Service Notes",
        "description": "Saves the practice's own notes on a client's service (HTML; plain text keeps its line breaks, blank clears them) and whether they show on the service's card. Targets the client's service by its own code. Touches nothing else on the service.\n\nRequires: Update on ClientBillableServices.",
        "operationId": "UpdateClientBillableServiceNotes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientBillableServiceNotesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/services/{code}/stage-history": {
      "get": {
        "tags": [
          "Client - Services"
        ],
        "summary": "Get Client Service Stage History",
        "description": "Returns the stage-change history for a client billable service, newest first — the audit trail behind time-in-stage reporting.\n\nRequires: ViewAll on ClientBillableServices.",
        "operationId": "GetClientBillableServiceStageHistory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientBillableServiceStageHistoryDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/services/clientbillableservice/{code}/history": {
      "get": {
        "tags": [
          "Client - Services"
        ],
        "summary": "Get Client Service History",
        "description": "Returns the change history of a client service, newest first: its price, billing period, package terms, setup and catch-up fees, which fees are overridden, quantity, start and end dates, status and auto-invoicing, who changed each and when, and the accepted proposal a change came from.\n\nRequires: ViewAll on ClientBillableServices.",
        "operationId": "GetClientBillableServiceHistory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientBillableServiceHistoryEntryDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-settings": {
      "get": {
        "tags": [
          "Client - Settings"
        ],
        "summary": "Get client settings",
        "description": "Returns the client settings for the specified tenant\n\nOpen to any signed-in user of the tenant: Practice-wide reference settings, readable by every user in the practice",
        "operationId": "GetClientSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientSettingsDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Practice-wide reference settings, readable by every user in the practice"
      },
      "put": {
        "tags": [
          "Client - Settings"
        ],
        "summary": "Update client settings",
        "description": "Updates the client settings for the specified tenant\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateClientSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/cis-manager/organisations/{organisationCode}/open": {
      "post": {
        "tags": [
          "Client - Sodium Products"
        ],
        "summary": "Open CIS Manager Organisation",
        "description": "Opens a CIS Manager organisation again from the organisation's code alone, for a user CIS Manager sent back because their access to it lapsed: finds the client linked to it in the signed-in user's practices, checks they can still see that client, makes them a member and grants a restricted user the organisation again, then returns where to open it: its landing page, or the page at path on its host (e.g. /returns/2026/4). 404 when none of their practices has it or they can no longer see the client; 400 for a path that is not one.\n\nRequires: ViewAll on ProductAccounts.",
        "operationId": "OpenCisManagerOrganisation",
        "parameters": [
          {
            "name": "organisationCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "path",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductAccountUrlDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/products/cis-manager": {
      "post": {
        "tags": [
          "Client - Sodium Products"
        ],
        "summary": "Set Up Client CIS Manager Account",
        "description": "Creates the client's CIS Manager organisation, owned by the signed-in user, and links it to the client. Repeating it returns the same organisation. Needs the client to have reached the Party Service (409 until it has).\n\nRequires: Create on ProductAccounts.",
        "operationId": "SetUpClientCisManagerAccount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductAccountUrlDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/products/cis-manager/linkable-organisations": {
      "get": {
        "tags": [
          "Client - Sodium Products"
        ],
        "summary": "List Client Linkable CIS Organisations",
        "description": "The CIS Manager organisations the signed-in user already has that the client could be linked to instead of creating one: those the practice runs that they can open, and their own in no practice, leaving out any linked to a client. Best match for the client's PAYE and Accounts Office references, UTR and name first. Empty when the client is linked already, the practice is not connected to CIS Manager, or the user has not joined the practice there yet.\n\nRequires: Create on ProductAccounts.",
        "operationId": "ListClientLinkableCisOrganisations",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LinkableCisOrganisationDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/products/cis-manager/link": {
      "post": {
        "tags": [
          "Client - Sodium Products"
        ],
        "summary": "Link Client CIS Manager Organisation",
        "description": "Links the client to a CIS Manager organisation the signed-in user already has (one of its linkable organisations) instead of creating one, and returns where to open it. CIS Manager fills the organisation in from the client's details, and adds it to the practice when it was the user's own outside it. Repeating it for the same organisation returns it. 409 when the client is linked to another organisation, the practice is not connected, the client has not reached the Party Service, or CIS Manager refuses (the organisation is linked to another client or in another practice).\n\nRequires: Create on ProductAccounts.",
        "operationId": "LinkClientCisManagerOrganisation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkClientCisManagerOrganisationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductAccountUrlDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/products/cis-manager/open": {
      "post": {
        "tags": [
          "Client - Sodium Products"
        ],
        "summary": "Open Client CIS Manager Account",
        "description": "Makes the signed-in user a member of the practice in CIS Manager, then returns where to open the client's organisation: its landing page, or the page at path on its host (e.g. /returns/2026/4). 400 for a path that is not one.\n\nRequires: ViewAll on ProductAccounts.",
        "operationId": "OpenClientCisManagerAccount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "path",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductAccountUrlDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/products/cis-manager/returns": {
      "get": {
        "tags": [
          "Client - Sodium Products"
        ],
        "summary": "Get Client CIS Manager Returns",
        "description": "The client's CIS return for the tax month in progress (null until CIS Manager has one) and the earlier returns needing attention: still open after their month ended, or in error. Read from CIS Manager. isContractor is false for a client that files no returns.\n\nRequires: ViewAll on ProductAccounts.",
        "operationId": "GetClientCisManagerReturns",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CisManagerReturnsDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/products/sodium-mtd": {
      "post": {
        "tags": [
          "Client - Sodium Products"
        ],
        "summary": "Set Up Client Sodium MTD Account",
        "description": "Creates the client in the practice's Sodium MTD tenant (provisioning the tenant on first use), makes the signed-in user a member, and links it to the client. Repeating it returns the same client. Needs the client to have reached the Party Service (409 until it has); refused (409) for a user restricted to some clients.\n\nRequires: Create on ProductAccounts.",
        "operationId": "SetUpClientSodiumMtdAccount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductAccountUrlDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/products/sodium-mtd/open": {
      "post": {
        "tags": [
          "Client - Sodium Products"
        ],
        "summary": "Open Client Sodium MTD Account",
        "description": "Makes the signed-in user a member of the practice's Sodium MTD tenant, then returns where to open the client. Refused (409) for a user restricted to some clients.\n\nRequires: ViewAll on ProductAccounts.",
        "operationId": "OpenClientSodiumMtdAccount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductAccountUrlDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clientbillableservices": {
      "get": {
        "tags": [
          "Client Billable Services"
        ],
        "summary": "List Client Service Summaries",
        "description": "Returns a paged list of client billable service summaries across all clients. Returns a lightweight projection (not the full DTO) designed for kanban board display. Filter by serviceCode and stageCode to load a single kanban column.\n\nRequires: ViewAll on ClientBillableServices.",
        "operationId": "ListClientBillableServiceSummaries",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "includeTasks",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          },
          {
            "name": "verbose",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientBillableServiceSummarySortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Filter by billable service code",
            "schema": {
              "type": "string",
              "example": "bookkeeping"
            }
          },
          {
            "name": "stageCode",
            "in": "query",
            "description": "Filter by stage code",
            "schema": {
              "type": "string",
              "example": "in-progress"
            }
          },
          {
            "name": "taskCategoryCode",
            "in": "query",
            "description": "Filter tasks on kanban cards by task category code",
            "schema": {
              "type": "string",
              "example": "vat"
            }
          },
          {
            "name": "clientManagerCode",
            "in": "query",
            "description": "Filter by client manager user code",
            "schema": {
              "type": "string",
              "example": "john-smith"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter by partner user code",
            "schema": {
              "type": "string",
              "example": "jane-doe"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by service assignment status",
            "schema": {
              "type": "string",
              "example": "Active"
            }
          },
          {
            "name": "managedByUserCode",
            "in": "query",
            "description": "Filter by managed-by user code",
            "schema": {
              "type": "string",
              "example": "john-smith"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across client name and code (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "acme"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillableServiceSummaryDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clientbillableservices/stage-counts": {
      "get": {
        "tags": [
          "Client Billable Services"
        ],
        "summary": "Get Client Service Stage Counts",
        "description": "Returns per-stage card counts for a service's kanban board, including each stage's display settings (icon, colour, sort order). One row per stage, including empty stages, in board display order. Designed for dashboard widgets — a single lightweight query instead of loading board columns. Pass clientManagerCode to scope the counts to one client manager's clients; stages with no matching cards stay in the list with a count of zero.\n\nRequires: ViewAll on ClientBillableServices.",
        "operationId": "GetClientBillableServiceStageCounts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientManagerCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "serviceCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/KanbanStageCountDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/billinglineitems": {
      "get": {
        "tags": [
          "Client Billing - Line Items"
        ],
        "summary": "List Billing Line Items",
        "description": "Returns a paged list of billing line items across all clients for the tenant. Supports filtering by status, client, and billing date range.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "ListBillingLineItems",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientBillingLineItemSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by line item status (Pending, Approved, Invoiced, Cancelled)",
            "schema": {
              "enum": [
                "Pending",
                "Approved",
                "Invoiced",
                "Cancelled"
              ],
              "type": "string",
              "example": "Pending"
            }
          },
          {
            "name": "clientBillableServiceCode",
            "in": "query",
            "description": "Filter by client billable service code",
            "schema": {
              "type": "string",
              "example": "cbs-001"
            }
          },
          {
            "name": "billableServiceCode",
            "in": "query",
            "description": "Filter by billable service code",
            "schema": {
              "type": "string",
              "example": "bs-001"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "ABC123"
            }
          },
          {
            "name": "billingDateFrom",
            "in": "query",
            "description": "Filter to line items with billing date on or after this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2025-01-01"
            }
          },
          {
            "name": "billingDateTo",
            "in": "query",
            "description": "Filter to line items with billing date on or before this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2025-12-31"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingLineItemDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/billingschedule/monthly-totals": {
      "get": {
        "tags": [
          "Client Billing - Schedule"
        ],
        "summary": "Get Schedule Monthly Totals",
        "description": "Planned billing by calendar month for the next 12 months across all clients: the count and total of scheduled items billing in each month, at today's prices.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "GetBillingScheduleMonthlyTotals",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BillingScheduleMonthTotalDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-billing-settings": {
      "get": {
        "tags": [
          "Client Billing - Settings"
        ],
        "summary": "Get client billing settings",
        "description": "Returns the client billing settings for the specified tenant\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "GetClientBilling-Settings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client Billing - Settings"
        ],
        "summary": "Update client billing settings",
        "description": "Updates the client billing settings for the specified tenant\n\nRequires: Update on ClientBilling.",
        "operationId": "UpdateClientBilling-Settings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientBillingSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientBillingSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/invoicesubmissions": {
      "get": {
        "tags": [
          "Client Billing - Submissions"
        ],
        "summary": "List Invoice Submissions",
        "description": "Returns a paged list of invoice submissions across all clients for the tenant. Supports filtering by status, client, and billing date range.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "ListInvoiceSubmissions",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientInvoiceSubmissionSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by submission status (Pending, Submitted, Failed)",
            "schema": {
              "enum": [
                "Pending",
                "Submitted",
                "Failed",
                "Projected"
              ],
              "type": "string",
              "example": "Failed"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "client-abc"
            }
          },
          {
            "name": "billingDateFrom",
            "in": "query",
            "description": "Filter to submissions with billing date on or after this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2025-01-01"
            }
          },
          {
            "name": "billingDateTo",
            "in": "query",
            "description": "Filter to submissions with billing date on or before this date (yyyy-MM-dd)",
            "schema": {
              "type": "string",
              "example": "2025-12-31"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientInvoiceSubmissionDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/contacts/{code}/portal-access": {
      "get": {
        "tags": [
          "Client Portal - Access"
        ],
        "summary": "Get Portal Access Status",
        "description": "Returns the portal access state for a contact on a client, including whether granting access would send an invitation email.\n\nRequires: ViewAll on ClientPortalSettings.",
        "operationId": "GetPortalAccessStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortalAccessStatusDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client Portal - Access"
        ],
        "summary": "Set Portal Access",
        "description": "Grant or revoke portal access for a contact on a client. When granting access, a PortalUser record is automatically created if one doesn't exist for the contact, and the invitation email is (re)sent unless the contact has already logged in to the portal.\n\nRequires: Update on ClientPortalSettings.",
        "operationId": "SetPortalAccess",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetPortalAccessRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientContactDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/contacts/{code}/portal-access/send-invitation": {
      "post": {
        "tags": [
          "Client Portal - Access"
        ],
        "summary": "Send Portal Invitation",
        "description": "Sends or re-sends the portal invitation email. The contact must already have portal access granted.\n\nRequires: Update on ClientPortalSettings.",
        "operationId": "SendPortalInvitation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortalUserDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-portal-settings": {
      "get": {
        "tags": [
          "Client Portal - Settings"
        ],
        "summary": "Get client portal settings",
        "description": "Returns the client portal settings for the specified tenant\n\nRequires: ViewAll on ClientPortalSettings.",
        "operationId": "GetClientPortalSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientPortalSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Client Portal - Settings"
        ],
        "summary": "Update client portal settings",
        "description": "Updates the client portal settings for the specified tenant\n\nRequires: Update on ClientPortalSettings.",
        "operationId": "UpdateClientPortalSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientPortalSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientPortalSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/portal-users": {
      "get": {
        "tags": [
          "Client Portal - Users"
        ],
        "summary": "List Portal Users",
        "description": "Returns a page of the portal users for this tenant.\n\nRequires: ViewAll on ClientPortalSettings.",
        "operationId": "ListPortalUsers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/PortalUserSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortalUserDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/portal-users/{code}": {
      "get": {
        "tags": [
          "Client Portal - Users"
        ],
        "summary": "Get Portal User",
        "description": "Returns a single portal user by code.\n\nRequires: ViewAll on ClientPortalSettings.",
        "operationId": "GetPortalUser",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortalUserDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/portal-users/{code}/status": {
      "put": {
        "tags": [
          "Client Portal - Users"
        ],
        "summary": "Update Portal User Status",
        "description": "Enable or disable a portal user account. Disabling prevents login without revoking per-client access grants.\n\nRequires: Update on ClientPortalSettings.",
        "operationId": "UpdatePortalUserStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePortalUserStatusRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortalUserDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientPortalSettings",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients": {
      "post": {
        "tags": [
          "Clients"
        ],
        "summary": "Create Client",
        "description": "Creates a new Client for the specified tenant.\n\nRequires: Create on Clients.",
        "operationId": "CreateClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateClientRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Create"
          }
        ]
      },
      "get": {
        "tags": [
          "Clients"
        ],
        "summary": "List Clients",
        "description": "Lists Clients for the given tenant.\n\nSupports filtering by manager, partner, associate, status, type, service, and search term.\nOptionally apply a saved filter by code — saved filter values are used unless explicitly overridden by query parameters.\n\nRequires: ViewAll on Clients.",
        "operationId": "ListClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "savedFilter",
            "in": "query",
            "description": "Code of a saved filter to apply. When provided, all filter parameters from the saved filter are used unless explicitly overridden by query parameters.",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "phone",
            "in": "query",
            "description": "Find the clients holding this phone number (main telephone or any extra number). Matches with or without the country code or leading zero, and ignores spaces, dashes, brackets and extensions. At least 7 digits",
            "schema": {
              "type": "string",
              "example": "+441225480112"
            }
          },
          {
            "name": "managerCode",
            "in": "query",
            "description": "Filter clients by their assigned manager's code (repeat parameter for multiple values)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "MGR001"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter clients by their assigned partner's code (repeat parameter for multiple values)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "PTR001"
            }
          },
          {
            "name": "associateCode",
            "in": "query",
            "description": "Filter clients by their assigned associate's code (repeat parameter for multiple values)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "ASC001"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter clients by status (repeat parameter for multiple values)",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "Active",
                  "Inactive",
                  "Prospect",
                  "LostProspect"
                ],
                "type": "string"
              },
              "example": "Active"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Filter clients by their organization type (repeat parameter for multiple values)",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "PrivateLimitedCompany",
                  "PublicLimitedCompany",
                  "LimitedLiabilityPartnership",
                  "Partnership",
                  "Individual",
                  "Trust",
                  "Charity",
                  "SoleTrader",
                  "Association"
                ],
                "type": "string"
              },
              "example": "PrivateLimitedCompany"
            }
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Filter clients by billable service codes they have assigned (repeat parameter for multiple values)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "SVC001"
            }
          },
          {
            "name": "hasNoService",
            "in": "query",
            "description": "Include clients with no services assigned. Can be combined with serviceCode to show clients with no services OR one of those services.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "packageCode",
            "in": "query",
            "description": "Filter clients by service package codes they have assigned (repeat parameter for multiple values)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "PKG001"
            }
          },
          {
            "name": "hasNoPackage",
            "in": "query",
            "description": "Include clients with no package assigned. Can be combined with packageCode to show clients with no package OR one of those packages.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "teamCode",
            "in": "query",
            "description": "Filter clients by their assigned team's code (repeat parameter for multiple values)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "TEAM001"
            }
          },
          {
            "name": "serviceStageCode",
            "in": "query",
            "description": "Filter clients by service stage using composite codes in the format serviceCode:stageCode (repeat parameter for multiple values)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "SVC001:in-progress"
            }
          },
          {
            "name": "serviceStatus",
            "in": "query",
            "description": "Only match services in these statuses when filtering by serviceCode or serviceStageCode; on its own, returns clients with any service in these statuses (repeat parameter for multiple values). Not given means any status.",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "Active",
                  "Inactive",
                  "Paused",
                  "Proposed"
                ],
                "type": "string"
              },
              "example": "Active"
            }
          },
          {
            "name": "customFieldFilter",
            "in": "query",
            "description": "Filter clients by custom field value using composite codes in the format fieldCode:value; use fieldCode: with an empty value to match clients where the field is blank (repeat parameter for multiple values — same field ORs, different fields AND)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "referral-source:Google"
            }
          },
          {
            "name": "keyDateType",
            "in": "query",
            "description": "Filter clients by one of their key dates. Names which key date the keyDateRange window applies to. Engine-computed date types (the VAT and MTD ITSA quarter dates) are not stored per client and cannot be filtered.",
            "schema": {
              "enum": [
                "IncorporationDate",
                "YearEnd",
                "AccountsNextDue",
                "AccountsNextPeriodStart",
                "AccountsNextPeriodEnd",
                "AccountsLastPeriodFiled",
                "AccountsLastPeriodStart",
                "AccountsLastPeriodEnd",
                "AccountsLastMadeUpTo",
                "ConfirmationStatementDue",
                "ConfirmationStatementNextMadeUpTo",
                "LastConfirmationStatementFiled",
                "LastConfirmationStatementMadeUpTo",
                "NextVatReturnDueAnnual",
                "NextVatPeriodEndQuarterly",
                "NextVatReturnDueQuarterly",
                "NextVatPeriodEndMonthly",
                "NextVatReturnDueMonthly",
                "NextTaxQuarterPeriodEnd",
                "NextTaxQuarterSubmissionDeadline",
                "NextPayeCisFilingDue",
                "PensionReEnrolmentDate",
                "CharityAnnualReturnDue",
                "CharityAccountsDue",
                "CharityLastAnnualReturnReceived",
                "CharityLastAccountsReceived",
                "CharityFinancialYearEnd"
              ],
              "type": "string",
              "example": "YearEnd"
            }
          },
          {
            "name": "keyDateRange",
            "in": "query",
            "description": "Preset window the chosen key date must fall within. If CustomDateRange, keyDateFrom and keyDateTo are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string",
              "example": "Next30Days"
            }
          },
          {
            "name": "keyDateFrom",
            "in": "query",
            "description": "Start of the key date window, inclusive. Only valid when keyDateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "keyDateTo",
            "in": "query",
            "description": "End of the key date window, inclusive. Only valid when keyDateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sortKeyDateType",
            "in": "query",
            "description": "Which key date to order by. Required when sortBy=KeyDate, ignored otherwise. Clients with no value for the date type always sort last, in both directions.",
            "schema": {
              "enum": [
                "IncorporationDate",
                "YearEnd",
                "AccountsNextDue",
                "AccountsNextPeriodStart",
                "AccountsNextPeriodEnd",
                "AccountsLastPeriodFiled",
                "AccountsLastPeriodStart",
                "AccountsLastPeriodEnd",
                "AccountsLastMadeUpTo",
                "ConfirmationStatementDue",
                "ConfirmationStatementNextMadeUpTo",
                "LastConfirmationStatementFiled",
                "LastConfirmationStatementMadeUpTo",
                "NextVatReturnDueAnnual",
                "NextVatPeriodEndQuarterly",
                "NextVatReturnDueQuarterly",
                "NextVatPeriodEndMonthly",
                "NextVatReturnDueMonthly",
                "NextTaxQuarterPeriodEnd",
                "NextTaxQuarterSubmissionDeadline",
                "NextPayeCisFilingDue",
                "PensionReEnrolmentDate",
                "CharityAnnualReturnDue",
                "CharityAccountsDue",
                "CharityLastAnnualReturnReceived",
                "CharityLastAccountsReceived",
                "CharityFinancialYearEnd"
              ],
              "type": "string",
              "example": "AccountsNextDue"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across client code, name and internal reference (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "acme"
            }
          },
          {
            "name": "missingRequiredData",
            "in": "query",
            "description": "Filter to clients missing at least one applicable required custom field value",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "patch": {
        "tags": [
          "Clients"
        ],
        "summary": "Bulk Update Clients",
        "description": "Updates multiple clients at once. Supports updating partner, manager, associate, PCL sent status, client status, and contact preferences (post, telephone, email, SMS). At least one update field must be provided. For role fields (PartnerCode, ManagerCode, AssociateCode): omit or null to leave unchanged, pass a user code to assign, or pass an empty string to unassign.\n\nRequires: Update on Clients.",
        "operationId": "BulkUpdateClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkUpdateClientsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{code}": {
      "get": {
        "tags": [
          "Clients"
        ],
        "summary": "Get Client",
        "description": "Gets a Client for the specified tenant.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Clients"
        ],
        "summary": "Update Client",
        "description": "Updates a Client for the specified tenant.\n\nRequires: Update on Clients.",
        "operationId": "UpdateClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Clients"
        ],
        "summary": "Delete Client",
        "description": "Deletes a Client for the specified tenant.\n\nRequires: Delete on Clients.",
        "operationId": "DeleteClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{code}/logo": {
      "put": {
        "tags": [
          "Clients"
        ],
        "summary": "Set Client Logo",
        "description": "Replaces the client's logo with the uploaded image (multipart/form-data, field 'file': PNG, JPEG or SVG up to 2 MB). The image is stored at a public web address, returned as logoUrl, and shared with the other Sodium products through the Party Service. Returns the updated client. Refused with a 400 when client logos are turned off in client settings.\n\nRequires: Update on Clients.",
        "operationId": "SetClientLogo",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Clients"
        ],
        "summary": "Remove Client Logo",
        "description": "Removes the client's logo, so the client is shown with its generated badge again. Returns the updated client.\n\nRequires: Update on Clients.",
        "operationId": "RemoveClientLogo",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{code}/resolve-recipients": {
      "post": {
        "tags": [
          "Clients"
        ],
        "summary": "Resolve Email Recipients",
        "description": "Resolves email recipient configuration (contact types, user roles, static emails) to actual email addresses for the specified client. Returns deduplicated list of recipients with names and email addresses.\n\nRequires: ViewAll on Clients.",
        "operationId": "ResolveClientEmailRecipients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailRecipientConfig"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmailRecipient"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{code}/tasks/summary": {
      "get": {
        "tags": [
          "Clients"
        ],
        "summary": "Task Summary",
        "description": "Returns a count of top-level tasks grouped by status for the specified client (excludes child tasks)\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetClientTaskSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskSummaryDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/third-party-mappings": {
      "get": {
        "tags": [
          "Clients"
        ],
        "summary": "List Third-Party Mappings",
        "description": "Returns a paged list of clients with their accounting, direct debit, AML and document storage folder mappings. Use the 'unmapped' query parameter to filter to clients missing a specific mapping (values: accounting, directdebit, aml, storage).\n\nRequires: ViewAll on Clients.",
        "operationId": "ListClientThirdPartyMappings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "unmapped",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ClientThirdPartyMappingSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientThirdPartyMappingDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{code}/third-party-mappings": {
      "patch": {
        "tags": [
          "Clients"
        ],
        "summary": "Update Third-Party Mapping",
        "description": "Updates the accounting, direct debit and/or AML mapping identifiers for a single client.\n\nRequires: Update on Clients.",
        "operationId": "UpdateClientThirdPartyMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateClientThirdPartyMappingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientThirdPartyMappingDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/companies-house-enrichments/preview": {
      "post": {
        "tags": [
          "Clients - Companies House Enrichment"
        ],
        "summary": "Preview Companies House Enrichment",
        "description": "Tells the user how many of the selected clients would be enriched from Companies House, and how many are skipped and why (a type with no Companies House record, no company number held, or already waiting to be enriched). Changes nothing. Returns 400 when Companies House is switched off for the practice or a code is unknown. Client visibility applies: a client the caller cannot see is an unknown code.\n\nRequires: Update on Clients.",
        "operationId": "PreviewCompaniesHouseEnrichment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompaniesHouseEnrichmentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompaniesHouseEnrichmentPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/companies-house-enrichments": {
      "post": {
        "tags": [
          "Clients - Companies House Enrichment"
        ],
        "summary": "Start Companies House Enrichment",
        "description": "Queues the selected clients that can be enriched from Companies House behind an import job and returns 202 Accepted with a Location header pointing to the import job status endpoint. The job's total is the number queued and its skipped count is the number left out. Returns 400 when none of the selected clients can be enriched, when Companies House is switched off for the practice, or when a code is unknown.\n\nRequires: Update on Clients.",
        "operationId": "StartCompaniesHouseEnrichment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompaniesHouseEnrichmentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJobDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/export/csv": {
      "post": {
        "tags": [
          "Clients - CSV Export"
        ],
        "summary": "Start CSV Export",
        "description": "Starts an async export of clients to CSV format. Optionally specify a saved mapping or inline column mappings to control the output format. If no mapping is provided, all fields are exported with enum names as headers. Use the filter options to select which clients to include. To export the clients of a saved view, send its savedFilterCode: the file holds every client the view matches, with all of its filters applied. Use either savedFilterCode or filter, not both: sending both returns 400. Client visibility applies: a restricted user exports only the clients they can see. Returns 201 Created with downloadUrl if the export completes within 10 seconds, or 202 Accepted with a Location header to poll for completion.\n\nRequires: Export on Clients.",
        "operationId": "StartClientCsvExport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CsvExportRequestDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvExportJobDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvExportJobDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/export/csv/{code}": {
      "get": {
        "tags": [
          "Clients - CSV Export"
        ],
        "summary": "Get Export Status",
        "description": "Returns the current status and progress of a CSV export job. Poll this endpoint after receiving a 202 Accepted response. When status is 'Completed', the downloadUrl field contains a time-limited link to download the CSV file.\n\nRequires: Export on Clients.",
        "operationId": "GetClientCsvExportStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvExportJobDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/import/csv": {
      "post": {
        "tags": [
          "Clients - CSV Import"
        ],
        "summary": "Upload Client CSV",
        "description": "Uploads a CSV file for importing clients. With showPreview=true (default), returns 201 with preview data. With showPreview=false and a mapping provided, returns 202 and starts import.\n\n**Header Detection:**\n- If `hasHeaderRow` is provided, that value is used\n- If `hasHeaderRow` is omitted, the system auto-detects by analyzing the first row for known header patterns (e.g., \"Company Name\", \"Email\") and data patterns (e.g., email addresses, phone numbers)\n- The response includes the actual `hasHeaderRow` value used (whether explicit or auto-detected)\n\n**Synthetic Headers:**\nWhen `hasHeaderRow` is false (explicitly or detected), the system generates synthetic column headers: Column1, Column2, Column3, etc. Use these synthetic names when creating column mappings for headerless CSV files.\n\nRequires: Import on Clients.",
        "operationId": "UploadCsvForImport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "description": "The CSV file to upload. Must be a valid CSV file with UTF-8 encoding.",
                    "format": "binary"
                  },
                  "hasHeaderRow": {
                    "type": "boolean",
                    "description": "Whether the CSV file has a header row. When true, the first row is treated as column headers. When false, synthetic column headers are generated (Column1, Column2, etc.) which can be used in column mappings. If not provided, the system will auto-detect based on the first row content."
                  },
                  "showPreview": {
                    "type": "boolean",
                    "description": "When true (default), returns a preview of the CSV data with auto-suggested mappings without starting the import. Set to false to start the import immediately (requires mapping to be provided)."
                  },
                  "mappingCode": {
                    "type": "string",
                    "description": "Code of a saved mapping to use. Either mappingCode or columnMappingsJson must be provided when showPreview=false."
                  },
                  "columnMappingsJson": {
                    "type": "string",
                    "description": "JSON array of column mappings for inline/ad-hoc mapping. Format: [{\"csvHeader\":\"Company Name\",\"targetField\":\"Name\"}]. Either mappingCode or columnMappingsJson must be provided when showPreview=false."
                  },
                  "matchField": {
                    "$ref": "#/components/schemas/CsvImportMatchField"
                  },
                  "importMode": {
                    "$ref": "#/components/schemas/CsvImportMode"
                  },
                  "enrichFromCompaniesHouse": {
                    "type": "boolean",
                    "description": "Whether to enrich newly created clients with Companies House data. Only applies to eligible company types (excludes Individual, SoleTrader, Trust, Association). Default: false."
                  },
                  "isContactImport": {
                    "type": "boolean"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                },
                "hasHeaderRow": {
                  "style": "form"
                },
                "showPreview": {
                  "style": "form"
                },
                "mappingCode": {
                  "style": "form"
                },
                "columnMappingsJson": {
                  "style": "form"
                },
                "matchField": {
                  "style": "form"
                },
                "importMode": {
                  "style": "form"
                },
                "enrichFromCompaniesHouse": {
                  "style": "form"
                },
                "isContactImport": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvUploadResponseDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvImportJobDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/import/csv/{code}": {
      "get": {
        "tags": [
          "Clients - CSV Import"
        ],
        "summary": "Get Import Status",
        "description": "Returns the current status and progress of a CSV import job. Poll this endpoint after receiving a 202 Accepted response.\n\nRequires: Import on Clients.",
        "operationId": "GetCsvImportStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvImportJobDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      },
      "put": {
        "tags": [
          "Clients - CSV Import"
        ],
        "summary": "Start CSV Import",
        "description": "Confirms the column mapping and starts the CSV import. Call after uploading with showPreview=true.\n\nRequires: Import on Clients.",
        "operationId": "ConfirmCsvImport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmCsvImportRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvImportJobDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvImportJobDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/import/available": {
      "get": {
        "tags": [
          "Clients - Platform Import"
        ],
        "summary": "List Available Clients",
        "description": "Returns a paginated list of clients available for import from the specified third-party connection. This endpoint does not import any data - it only lists what is available. Shows which clients have already been imported via the ImportedAs field (IsLinked when linked by hand), and suggests the existing Sodium client each of the others most likely is via SuggestedMatch.\n\nRequires: Import on Clients.",
        "operationId": "GetAvailableClientsForImport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "connectionCode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AvailableClientDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "502": {
            "description": "Bad Gateway",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/import/from-connection": {
      "post": {
        "tags": [
          "Clients - Platform Import"
        ],
        "summary": "Import clients from a third-party connection",
        "description": "Imports clients from the third-party platform. This endpoint uses a hybrid approach: it queues the import job and waits up to 10 seconds for completion. For small imports (5-20 clients), the job typically completes within this window and returns 201 Created with the final result. For larger imports that take longer, it returns 202 Accepted with a Location header pointing to the import job status endpoint. The request body chooses which clients to import (all, or the listed external IDs), the client type to give clients the platform gives no company signal for, and whether to enrich eligible companies with Companies House data (excludes Individual, SoleTrader, Trust, Association). Links in the body are made first, one at a time under the map-client rules; each refusal is reported in LinkFailures and the rest go ahead. Import All leaves out clients that match one already in Sodium (LeftForReviewCount). A request with links alone queues no import and returns 200 OK with the link results.\n\nRequires: Import on Clients.",
        "operationId": "ImportClientsFromConnection",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "connectionCode",
            "in": "query",
            "description": "The code of the third-party connection to import from (e.g., 'xero-abc123')",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "description": "Which clients to import and the import options",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientImportRequestDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientImportResponseDto"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientImportResponseDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientImportResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientImportResponseDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/import/map-client": {
      "post": {
        "tags": [
          "Clients - Platform Import"
        ],
        "summary": "Map External Client",
        "description": "Manually maps an external platform client to an existing Sodium client. Creates an ImportedClients record with IsManuallyMapped = true, allowing the external client to be linked without importing a new record. A Sodium client already linked to a client on the same platform cannot be linked again.\n\nRequires: Import on Clients.",
        "operationId": "MapExternalClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "connectionCode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MapExternalClientRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/saved-client-filters": {
      "get": {
        "tags": [
          "Clients - Saved Filters"
        ],
        "summary": "List SavedClientFilters",
        "description": "Lists the saved client filters visible to the current user within the tenant: their own filters plus any shared with the practice.\n\nRequires: ViewAll on Clients.",
        "operationId": "ListSavedClientFilters",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/SavedClientFilterSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "menuOnly",
            "in": "query",
            "description": "Filter to only show filters marked for menu display",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across saved view name and description",
            "schema": {
              "type": "string",
              "example": "vat"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedClientFilterDtoPagedResult"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Clients - Saved Filters"
        ],
        "summary": "Create SavedClientFilter",
        "description": "Creates a new saved client filter owned by the current user.\n\nRequires: ViewAll on Clients.",
        "operationId": "CreateSavedClientFilter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSavedClientFilterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedClientFilterDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/saved-client-filters/{code}": {
      "get": {
        "tags": [
          "Clients - Saved Filters"
        ],
        "summary": "Get SavedClientFilter",
        "description": "Gets a specific saved client filter by code. Only filters owned by or shared with the current user are accessible.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetSavedClientFilter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedClientFilterDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Clients - Saved Filters"
        ],
        "summary": "Update SavedClientFilter",
        "description": "Updates an existing saved client filter. Only the owner can update a filter.\n\nRequires: ViewAll on Clients.",
        "operationId": "UpdateSavedClientFilter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSavedClientFilterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedClientFilterDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "delete": {
        "tags": [
          "Clients - Saved Filters"
        ],
        "summary": "Delete SavedClientFilter",
        "description": "Deletes a saved client filter. Only the owner can delete a filter.\n\nRequires: ViewAll on Clients.",
        "operationId": "DeleteSavedClientFilter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/saved-client-filters/menu-order": {
      "put": {
        "tags": [
          "Clients - Saved Filters"
        ],
        "summary": "Set Menu Order",
        "description": "Sets the order of the current user's saved client view menu entries. Codes must be supplied in display order. This is a per-user preference and does not affect other users.\n\nRequires: ViewAll on Clients.",
        "operationId": "SetSavedClientFilterMenuOrder",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetSavedFilterMenuOrderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/saved-client-filters/{code}/menu": {
      "put": {
        "tags": [
          "Clients - Saved Filters"
        ],
        "summary": "Set Menu Preference",
        "description": "Sets whether this saved client filter appears in the current user's menu. This is a per-user preference and does not affect other users.\n\nRequires: ViewAll on Clients.",
        "operationId": "SetSavedClientFilterMenuPreference",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetSavedFilterMenuRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-services/import/csv/preview": {
      "post": {
        "tags": [
          "Clients - Services - Import"
        ],
        "summary": "Preview Service CSV Import",
        "description": "Uploads a native-format CSV and returns a preview of what the import will do: new assignments, updates to existing assignments, and unchanged assignments. The file is stored for the confirm step.\n\nRequires: Import on Clients.",
        "operationId": "PreviewServiceCsvImport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file",
                  "matchField"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "matchField": {
                    "$ref": "#/components/schemas/CsvImportMatchField"
                  },
                  "createOnboardingTasks": {
                    "type": "boolean"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                },
                "matchField": {
                  "style": "form"
                },
                "createOnboardingTasks": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceImportPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-services/import/csv/{code}/confirm": {
      "put": {
        "tags": [
          "Clients - Services - Import"
        ],
        "summary": "Confirm Service CSV Import",
        "description": "Confirms a previously previewed import and queues it for background processing. Returns 201 if completed within 10 seconds, 202 if still processing.\n\nRequires: Import on Clients.",
        "operationId": "ConfirmServiceCsvImport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceImportJobDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceImportJobDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-services/import/csv/export": {
      "get": {
        "tags": [
          "Clients - Services - Import"
        ],
        "summary": "Export Client Services CSV",
        "description": "Downloads all client service assignments as a CSV file. Use this as a template for the native import format.\n\nRequires: Import on Clients.",
        "operationId": "ExportServicesCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "serviceCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-services/import/csv/{code}": {
      "get": {
        "tags": [
          "Clients - Services - Import"
        ],
        "summary": "Get Service Import Status",
        "description": "Returns the current status and progress of a service import job. Poll this endpoint after starting the import.\n\nRequires: Import on Clients.",
        "operationId": "GetServiceImportStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceImportJobDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-services/import/csv/analyze": {
      "post": {
        "tags": [
          "Clients - Services - Import"
        ],
        "summary": "Analyze Service CSV",
        "description": "Auto-detects the source format (Engager or Bright AM) and returns the detected source, whether it carries per-service pricing, and its detected services with client counts. Stateless: no data is persisted.\n\nRequires: Import on Clients.",
        "operationId": "AnalyzeServiceCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCsvAnalysisDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/client-services/import/csv/convert": {
      "post": {
        "tags": [
          "Clients - Services - Import"
        ],
        "summary": "Convert Service CSV to Native Format",
        "description": "Auto-detects the source format and converts the file plus service mappings into a native-format CSV for download. Stateless: no data is persisted.\n\nRequires: Import on Clients.",
        "operationId": "ConvertServiceCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file",
                  "mappings"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "mappings": {
                    "type": "string"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                },
                "mappings": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/companies-house/search": {
      "get": {
        "tags": [
          "Companies House"
        ],
        "summary": "Search",
        "description": "Search the Companies House register for companies matching the query - either name or number\n\nRequires: ViewAll on Clients.",
        "operationId": "SearchCompanies",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "itemsPerPage",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20
            },
            "x-order": 400
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "startIndex",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanySearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/companies-house/{companyNumber}": {
      "get": {
        "tags": [
          "Companies House"
        ],
        "summary": "Get Company Details",
        "description": "Retrieve detailed information about a specific company\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCompanyDetails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "companyNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Company"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/companies-house/{companyNumber}/officers": {
      "get": {
        "tags": [
          "Companies House"
        ],
        "summary": "Get Company Officers",
        "description": "Retrieve the list of current and former officers for a company\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCompanyOfficers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "companyNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Officer"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/companies-house/{companyNumber}/pscs": {
      "get": {
        "tags": [
          "Companies House"
        ],
        "summary": "Get Company PSCs",
        "description": "Retrieve the list of current and ceased individual Persons with Significant Control for a company\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCompanyPscs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "companyNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CompaniesHousePsc"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/companies-house/{companyNumber}/key-dates": {
      "get": {
        "tags": [
          "Companies House"
        ],
        "summary": "Get Key Dates",
        "description": "Retrieve important upcoming dates for a company\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCompanyKeyDates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "companyNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientDateDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/companies-house/{companyNumber}/filing-history": {
      "get": {
        "tags": [
          "Companies House"
        ],
        "summary": "Get Filing History",
        "description": "Retrieve the filing history for a company\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCompanyFilingHistory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 203
          },
          {
            "name": "companyNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "itemsPerPage",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 25
            },
            "x-order": 400
          },
          {
            "name": "startIndex",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingHistoryItemPagedResult"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/companies-house/{companyNumber}/filing-history/{transactionId}": {
      "get": {
        "tags": [
          "Companies House"
        ],
        "summary": "Get Filing Details",
        "description": "Retrieve detailed information about a specific filing\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCompanyFiling",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "companyNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "transactionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingHistoryItem"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/companies-house/{companyNumber}/documents/{documentId}": {
      "get": {
        "tags": [
          "Companies House"
        ],
        "summary": "Get Document",
        "description": "Retrieve a specific document from Companies House\n\nRequires: ViewAll on Clients.",
        "operationId": "GetCompanyDocument",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "companyNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "documentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "404": {
            "description": "Not Found"
          },
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/contacts": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "List Contacts",
        "description": "Lists all Contacts for the given tenant.\n\nRequires: ViewAll on Contacts.",
        "operationId": "ListContacts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ContactSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code - only show contacts associated with this client",
            "schema": {
              "type": "string",
              "example": "CLI001"
            }
          },
          {
            "name": "clientLinks",
            "in": "query",
            "description": "Filter by client links: AnyClient (at least one), Unassigned (none) or Multiple (two or more)",
            "schema": {
              "enum": [
                "AnyClient",
                "Unassigned",
                "Multiple"
              ],
              "type": "string",
              "example": "Unassigned"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "description": "Find the contacts holding this phone number (main phone, mobile or any extra number). Matches with or without the country code or leading zero, and ignores spaces, dashes, brackets and extensions. At least 7 digits. Each contact comes back with every client it is linked to",
            "schema": {
              "type": "string",
              "example": "+447782318874"
            }
          },
          {
            "name": "hasEmail",
            "in": "query",
            "description": "True for contacts with a main email address, false for contacts without one",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "isFromCompaniesHouse",
            "in": "query",
            "description": "True for contacts imported from Companies House officers, false for all others",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "hasPortalAccess",
            "in": "query",
            "description": "True for contacts with active client portal access, false for contacts without",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "hasDuplicates",
            "in": "query",
            "description": "True for contacts that are likely the same person as another contact, grouped by duplicateGroup, most certain groups first, each with the clients it is linked to. Paging (offset, limit, totalCount) counts groups, not contacts. False for contacts with no likely duplicates",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "duplicateConfidence",
            "in": "query",
            "description": "With hasDuplicates=true, only the groups of this confidence: Certain, Strong or Possible",
            "schema": {
              "enum": [
                "Possible",
                "Strong",
                "Certain"
              ],
              "type": "string",
              "example": "Certain"
            }
          },
          {
            "name": "duplicateMergeStatus",
            "in": "query",
            "description": "With hasDuplicates=true, only the groups with this merge status: Ready, DetailsToChoose, CheckSamePerson or Blocked",
            "schema": {
              "enum": [
                "Ready",
                "DetailsToChoose",
                "CheckSamePerson",
                "Blocked"
              ],
              "type": "string",
              "example": "Ready"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across contact details: code, name, email, phone (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "john"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "Create Contact",
        "description": "Creates a new Contact for the specified tenant.\n\nRequires: Create on Contacts.",
        "operationId": "CreateContact",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateContactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "Create"
          }
        ]
      },
      "delete": {
        "tags": [
          "Contacts"
        ],
        "summary": "Bulk Delete Contacts",
        "description": "Deletes multiple contacts at once, removing any client portal access they have. Contacts still linked to a client are not deleted and are returned in skippedCodes. Unknown codes are ignored.\n\nRequires: Delete on Contacts.",
        "operationId": "BulkDeleteContacts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkDeleteContactsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeleteContactsResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/contacts/{code}": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "Get Contact",
        "description": "Gets a Contact for the specified tenant.\n\nRequires: ViewAll on Contacts.",
        "operationId": "GetContact",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "hasDuplicates",
            "in": "query",
            "description": "True to return whether this contact has likely duplicates, and which: duplicates lists them (empty when there are none), with duplicateGroup, duplicateConfidence and duplicateReasons.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Contacts"
        ],
        "summary": "Update Contact",
        "description": "Updates a Contact for the specified tenant.\n\nRequires: Update on Contacts.",
        "operationId": "UpdateContact",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateContactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Contacts"
        ],
        "summary": "Delete Contact",
        "description": "Deletes a Contact for the specified tenant.\n\nRequires: Delete on Contacts.",
        "operationId": "DeleteContact",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/contacts/{code}/clients": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "List Contact Clients",
        "description": "Returns a list of clients that have the specified contact associated with them\n\nRequires: ViewAll on ClientContacts and ViewAll on Clients.",
        "operationId": "GetClientsForContact",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientContactDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientContacts",
            "permission": "ViewAll"
          },
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/contacts/match": {
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "Match Contacts",
        "description": "Given a batch of people - a company's Companies House officers, typically - returns the existing contacts that could be each of them, with how sure we are: certain (the same Companies House officer id), strong (the same name and email address or month of birth) or possible (the same name and nothing else). Contacts that contradict a person are not returned. Nothing is created or changed.\n\nRequires: ViewAll on Contacts.",
        "operationId": "MatchContacts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MatchContactsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ContactMatchResultDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/contacts/{code}/merge": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "Preview Contact Merge",
        "description": "Shows what this contact would look like with the contacts in `with` (repeated, 1 to 5) merged into it: each field's values, every email and phone number, what happens to each client and the portal login, the merged contact by the default rules, and any blockers or warnings. Nothing is changed.\n\nRequires: ViewAll on Contacts.",
        "operationId": "PreviewContactMerge",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "with",
            "in": "query",
            "required": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactMergePreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "Merge Contacts",
        "description": "Merges the listed contacts into this contact and saves it exactly as `contact` (a full replace). Their client links move to this contact, or combine with its own on the same client. The one active portal login moves to this contact, replacing an inactive login it has. Document references are re-pointed, and the merged contacts are permanently deleted. Cannot be undone. Returns 400 with `blockers` when the contacts cannot be merged, and 409 when one of them changed during the merge.\n\nRequires: Delete on Contacts.",
        "operationId": "MergeContacts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MergeContactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/contacts/export/csv": {
      "post": {
        "tags": [
          "Contacts - CSV Export"
        ],
        "summary": "Start Contacts CSV Export",
        "description": "Starts an async export of the practice's contacts to CSV, optionally filtered as on the contacts list, one row per client the contact is linked to (a contact with no clients has one row). The columns match the contacts import, including each client's code, company number, internal reference and NI number to match on. Returns 201 Created with downloadUrl if the export completes within 10 seconds, or 202 Accepted with a Location header to poll for completion.\n\nRequires: Export on Contacts.",
        "operationId": "StartContactCsvExport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactCsvExportRequestDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvExportJobDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvExportJobDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/contacts/export/csv/{code}": {
      "get": {
        "tags": [
          "Contacts - CSV Export"
        ],
        "summary": "Get Contacts Export Status",
        "description": "Returns the status and progress of a contacts CSV export. When status is 'Completed', downloadUrl holds a time-limited link to the CSV file.\n\nRequires: Export on Contacts.",
        "operationId": "GetContactCsvExportStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvExportJobDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Contacts",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks": {
      "get": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "List ContentBlocks",
        "description": "Lists all ContentBlocks for the given tenant.\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "ListContentBlocks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ContentBlockSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter content blocks by category",
            "schema": {
              "enum": [
                "Custom",
                "ServiceTerms",
                "ServiceProposals",
                "TemplateParts",
                "WebContent",
                "Email",
                "EmailParts",
                "AdHocEmails"
              ],
              "type": "string",
              "example": "Custom"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across content block code and name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "footer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentBlockDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Create ContentBlock",
        "description": "Creates a new ContentBlock for the specified tenant.\n\nRequires: Create on ContentBlocks.",
        "operationId": "CreateContentBlock",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateContentBlockRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentBlockDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks/{code}": {
      "get": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Get ContentBlock",
        "description": "Gets a ContentBlock for the specified tenant.\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "GetContentBlock",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentBlockDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Update ContentBlock",
        "description": "Updates a ContentBlock for the specified tenant.\n\nRequires: Update on ContentBlocks.",
        "operationId": "UpdateContentBlock",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateContentBlockRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentBlockDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Delete ContentBlock",
        "description": "Deletes a ContentBlock for the specified tenant.\n\nRequires: Delete on ContentBlocks.",
        "operationId": "DeleteContentBlock",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks/library": {
      "get": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "List Library ContentBlocks",
        "description": "List all ContentBlocks available in the library as templates. Use optional 'search' query parameter to filter by Code, Name, or Description.\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "ListLibraryContentBlocks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ContentBlockDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks/library/{code}": {
      "get": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Get Library ContentBlock",
        "description": "Get details of a specific ContentBlock template from the library\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "GetLibraryContentBlock",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentBlockDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks/{code}/library-version": {
      "put": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Revert ContentBlock to Library",
        "description": "Reverts the ContentBlock to the current library template version, overwriting any local edits. The ContentBlock's code is preserved so it remains addressable at the same URL. Returns 400 if the ContentBlock was not imported from the library, or 404 if the ContentBlock or its source library template no longer exists.\n\nRequires: Update on ContentBlocks.",
        "operationId": "RevertContentBlockToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentBlockDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks/template-variables": {
      "get": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Get Template Variables",
        "description": "Returns template variables for content block rendering. When a clientCode is provided, variables are populated with client, partner, manager, practice, contacts, key dates, and custom fields. Otherwise only practice details are included.\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "GetContentBlockTemplateVariables",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateVariables"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks/{code}/render": {
      "post": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Render Content Block",
        "description": "Renders a content block's body HTML with Liquid tokens resolved using the provided template variables. When includeEmailBranding is true, wraps the result with the tenant's email header, footer, and design theme. Returns the rendered HTML string.\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "RenderContentBlock",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderContentBlockRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      },
      "get": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Preview Content Block",
        "description": "Renders a content block by code with template variables built server-side. When clientCode is supplied, hydrates client/business/contacts/practice/key dates/custom fields. Otherwise renders with practice details and date/year tokens only. Returns text/html so the response can be opened directly in a browser.\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "PreviewContentBlock",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "clientCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks/render-template": {
      "post": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Render Template String",
        "description": "Renders an arbitrary Liquid template string (e.g. a subject line) with the provided template variables. Returns the rendered string.\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "RenderTemplateString",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderTemplateStringRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks/{code}/email-tokens": {
      "get": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Get Content Block Email Tokens",
        "description": "Reads a content block's tokens, including any blocks it includes, and says whether a client must be chosen, whether recipient tokens are used, and which tokens a one-off email cannot complete.\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "GetContentBlockEmailTokens",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentBlockEmailTokensDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/contentblocks/{code}/render-email": {
      "post": {
        "tags": [
          "Content Blocks"
        ],
        "summary": "Render Content Block Email",
        "description": "Completes a content block's subject and body for a one-off email, from the client and To addresses given. The result has no email header or footer, because the composer adds those on send.\n\nRequires: ViewAll on ContentBlocks.",
        "operationId": "RenderContentBlockEmail",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderContentBlockEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RenderedContentBlockEmailDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ContentBlocks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/csv-mappings": {
      "get": {
        "tags": [
          "CSV Mappings"
        ],
        "summary": "List CsvMappings",
        "description": "Lists all CsvMappings for the given tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "ListCsvMappings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/CsvMappingSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "mappingType",
            "in": "query",
            "description": "Filter by mapping type",
            "schema": {
              "enum": [
                "Client"
              ],
              "type": "string",
              "example": "Client"
            }
          },
          {
            "name": "isPreset",
            "in": "query",
            "description": "Filter by preset mappings",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across mapping name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "limited company"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvMappingDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "CSV Mappings"
        ],
        "summary": "Create CsvMapping",
        "description": "Creates a new CsvMapping for the specified tenant.\n\nRequires: Create on PracticeDetails.",
        "operationId": "CreateCsvMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCsvMappingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvMappingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/csv-mappings/{code}": {
      "get": {
        "tags": [
          "CSV Mappings"
        ],
        "summary": "Get CsvMapping",
        "description": "Gets a CsvMapping for the specified tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetCsvMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvMappingDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "CSV Mappings"
        ],
        "summary": "Update CsvMapping",
        "description": "Updates a CsvMapping for the specified tenant.\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateCsvMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCsvMappingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvMappingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "CSV Mappings"
        ],
        "summary": "Delete CsvMapping",
        "description": "Deletes a CsvMapping for the specified tenant.\n\nRequires: Delete on PracticeDetails.",
        "operationId": "DeleteCsvMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/custom-field-groups": {
      "get": {
        "tags": [
          "Custom Field - Groups"
        ],
        "summary": "List CustomFieldGroups",
        "description": "Lists all CustomFieldGroups for the given tenant.\n\nRequires: ViewAll on CustomFields.",
        "operationId": "ListCustomFieldGroups",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/CustomFieldGroupSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "entityType",
            "in": "query",
            "description": "Filter by entity type",
            "schema": {
              "enum": [
                "Client"
              ],
              "type": "string",
              "example": "Client"
            }
          },
          {
            "name": "clientType",
            "in": "query",
            "description": "Only return groups that contain at least one active field applicable to this client type",
            "schema": {
              "enum": [
                "PrivateLimitedCompany",
                "PublicLimitedCompany",
                "LimitedLiabilityPartnership",
                "Partnership",
                "Individual",
                "Trust",
                "Charity",
                "SoleTrader",
                "Association"
              ],
              "type": "string",
              "example": "PrivateLimitedCompany"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Only return groups that contain at least one active field whose service restriction is satisfied by this client's services. Combine with clientType for the full applicability check.",
            "schema": {
              "type": "string",
              "example": "CLI-0001"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldGroupDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Custom Field - Groups"
        ],
        "summary": "Create CustomFieldGroup",
        "description": "Creates a new CustomFieldGroup for the specified tenant.\n\nRequires: Create on CustomFields.",
        "operationId": "CreateCustomFieldGroup",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomFieldGroupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldGroupDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/custom-field-groups/{code}": {
      "get": {
        "tags": [
          "Custom Field - Groups"
        ],
        "summary": "Get CustomFieldGroup",
        "description": "Gets a CustomFieldGroup for the specified tenant.\n\nRequires: ViewAll on CustomFields.",
        "operationId": "GetCustomFieldGroup",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldGroupDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Custom Field - Groups"
        ],
        "summary": "Update CustomFieldGroup",
        "description": "Updates a CustomFieldGroup for the specified tenant.\n\nRequires: Update on CustomFields.",
        "operationId": "UpdateCustomFieldGroup",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomFieldGroupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldGroupDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Custom Field - Groups"
        ],
        "summary": "Delete CustomFieldGroup",
        "description": "Deletes a CustomFieldGroup for the specified tenant.\n\nRequires: Delete on CustomFields.",
        "operationId": "DeleteCustomFieldGroup",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/custom-fields": {
      "get": {
        "tags": [
          "Custom Fields"
        ],
        "summary": "List CustomFieldDefinitions",
        "description": "Lists all CustomFieldDefinitions for the given tenant.\n\nRequires: ViewAll on CustomFields.",
        "operationId": "ListCustomFieldDefinitions",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/CustomFieldDefinitionSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "entityType",
            "in": "query",
            "description": "Filter by entity type",
            "schema": {
              "enum": [
                "Client"
              ],
              "type": "string",
              "example": "Client"
            }
          },
          {
            "name": "dataType",
            "in": "query",
            "description": "Filter by data type",
            "schema": {
              "enum": [
                "Text",
                "Number",
                "Date",
                "Boolean",
                "Select",
                "MultiSelect",
                "TextArea",
                "Address",
                "Email",
                "File",
                "Link",
                "RichText"
              ],
              "type": "string",
              "example": "Date"
            }
          },
          {
            "name": "clientType",
            "in": "query",
            "description": "Filter by applicable client type. Returns fields that explicitly include this type, or have no types specified (applicable to all).",
            "schema": {
              "enum": [
                "PrivateLimitedCompany",
                "PublicLimitedCompany",
                "LimitedLiabilityPartnership",
                "Partnership",
                "Individual",
                "Trust",
                "Charity",
                "SoleTrader",
                "Association"
              ],
              "type": "string",
              "example": "PrivateLimitedCompany"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by the services this client holds. Returns fields restricted to one of the client's services, or with no service restriction at all. Combine with clientType for the full applicability check.",
            "schema": {
              "type": "string",
              "example": "CLI-0001"
            }
          },
          {
            "name": "isArchived",
            "in": "query",
            "description": "Filter by archived status (true = archived only, false = active only)",
            "schema": {
              "type": "boolean",
              "example": "false"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across field code and label (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "company"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldDefinitionDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Custom Fields"
        ],
        "summary": "Create CustomFieldDefinition",
        "description": "Creates a new CustomFieldDefinition for the specified tenant.\n\nRequires: Create on CustomFields.",
        "operationId": "CreateCustomFieldDefinition",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomFieldDefinitionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldDefinitionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/custom-fields/{code}": {
      "get": {
        "tags": [
          "Custom Fields"
        ],
        "summary": "Get CustomFieldDefinition",
        "description": "Gets a CustomFieldDefinition for the specified tenant.\n\nRequires: ViewAll on CustomFields.",
        "operationId": "GetCustomFieldDefinition",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldDefinitionDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Custom Fields"
        ],
        "summary": "Update CustomFieldDefinition",
        "description": "Updates a CustomFieldDefinition for the specified tenant.\n\nRequires: Update on CustomFields.",
        "operationId": "UpdateCustomFieldDefinition",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomFieldDefinitionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldDefinitionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Custom Fields"
        ],
        "summary": "Delete CustomFieldDefinition",
        "description": "Deletes a CustomFieldDefinition for the specified tenant.\n\nRequires: Delete on CustomFields.",
        "operationId": "DeleteCustomFieldDefinition",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "CustomFields",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/custom-tokens": {
      "get": {
        "tags": [
          "Custom Tokens"
        ],
        "summary": "List CustomTokens",
        "description": "Lists all CustomTokens for the given tenant.\n\nRequires: ViewAll on Templates.",
        "operationId": "ListCustomTokens",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/CustomTokenSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomTokenDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Custom Tokens"
        ],
        "summary": "Create CustomToken",
        "description": "Creates a new CustomToken for the specified tenant.\n\nRequires: Create on Templates.",
        "operationId": "CreateCustomToken",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomTokenDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/custom-tokens/{code}": {
      "get": {
        "tags": [
          "Custom Tokens"
        ],
        "summary": "Get CustomToken",
        "description": "Gets a CustomToken for the specified tenant.\n\nRequires: ViewAll on Templates.",
        "operationId": "GetCustomToken",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomTokenDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Custom Tokens"
        ],
        "summary": "Update CustomToken",
        "description": "Updates a CustomToken for the specified tenant.\n\nRequires: Update on Templates.",
        "operationId": "UpdateCustomToken",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomTokenDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Custom Tokens"
        ],
        "summary": "Delete CustomToken",
        "description": "Deletes a CustomToken for the specified tenant.\n\nRequires: Delete on Templates.",
        "operationId": "DeleteCustomToken",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/dashboard-links": {
      "get": {
        "tags": [
          "Dashboard Links"
        ],
        "summary": "List Dashboard Links",
        "description": "Lists one list of links in display order: the calling user's own, or the one shared across the practice.\n\nOpen to any signed-in user of the tenant: The caller's own links, and the shared list every user in the practice can read and change",
        "operationId": "ListDashboardLinks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "scope",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/DashboardLinkScope"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DashboardLinkDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own links, and the shared list every user in the practice can read and change"
      },
      "post": {
        "tags": [
          "Dashboard Links"
        ],
        "summary": "Create Dashboard Link",
        "description": "Adds a link to the end of a list. https:// is assumed when the URL has no scheme; anything but http and https is rejected.\n\nOpen to any signed-in user of the tenant: The caller's own links, and the shared list every user in the practice can read and change",
        "operationId": "CreateDashboardLink",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDashboardLinkRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardLinkDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own links, and the shared list every user in the practice can read and change"
      },
      "patch": {
        "tags": [
          "Dashboard Links"
        ],
        "summary": "Reorder Dashboard Links",
        "description": "Saves the new order of one list in a single change. Each code's sort order becomes its 0-based position.\nRejected when the list is empty or contains duplicates. A code that is not on the list is skipped, because\nsomebody else may have just deleted it from the shared one.\n\nOpen to any signed-in user of the tenant: The caller's own links, and the shared list every user in the practice can read and change",
        "operationId": "ReorderDashboardLinks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReorderDashboardLinksRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own links, and the shared list every user in the practice can read and change"
      }
    },
    "/tenants/{tenant}/dashboard-links/{code}": {
      "get": {
        "tags": [
          "Dashboard Links"
        ],
        "summary": "Get Dashboard Link",
        "description": "Gets one link. Returns 404 for a link on another user's own list.\n\nOpen to any signed-in user of the tenant: The caller's own links, and the shared list every user in the practice can read and change",
        "operationId": "GetDashboardLink",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardLinkDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own links, and the shared list every user in the practice can read and change"
      },
      "put": {
        "tags": [
          "Dashboard Links"
        ],
        "summary": "Update Dashboard Link",
        "description": "Changes a link's URL and title. Returns 404 for a link on another user's own list.\n\nOpen to any signed-in user of the tenant: The caller's own links, and the shared list every user in the practice can read and change",
        "operationId": "UpdateDashboardLink",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDashboardLinkRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardLinkDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own links, and the shared list every user in the practice can read and change"
      },
      "delete": {
        "tags": [
          "Dashboard Links"
        ],
        "summary": "Delete Dashboard Link",
        "description": "Deletes a link. Returns 404 for a link on another user's own list.\n\nOpen to any signed-in user of the tenant: The caller's own links, and the shared list every user in the practice can read and change",
        "operationId": "DeleteDashboardLink",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own links, and the shared list every user in the practice can read and change"
      }
    },
    "/tenants/{tenant}/data-form-categories": {
      "get": {
        "tags": [
          "Data Form - Categories"
        ],
        "summary": "List DataFormCategories",
        "description": "Lists all DataFormCategories for the given tenant.\n\nRequires: ViewAll on DataForms.",
        "operationId": "ListDataFormCategories",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/DataFormCategorySortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormCategoryDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Data Form - Categories"
        ],
        "summary": "Create DataFormCategory",
        "description": "Creates a new DataFormCategory for the specified tenant.\n\nRequires: Create on DataForms.",
        "operationId": "CreateDataFormCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDataFormCategoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormCategoryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-categories/{code}": {
      "get": {
        "tags": [
          "Data Form - Categories"
        ],
        "summary": "Get DataFormCategory",
        "description": "Gets a DataFormCategory for the specified tenant.\n\nRequires: ViewAll on DataForms.",
        "operationId": "GetDataFormCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormCategoryDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Data Form - Categories"
        ],
        "summary": "Update DataFormCategory",
        "description": "Updates a DataFormCategory for the specified tenant.\n\nRequires: Update on DataForms.",
        "operationId": "UpdateDataFormCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDataFormCategoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormCategoryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Data Form - Categories"
        ],
        "summary": "Delete DataFormCategory",
        "description": "Deletes a DataFormCategory for the specified tenant.\n\nRequires: Delete on DataForms.",
        "operationId": "DeleteDataFormCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests": {
      "get": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "List DataFormRequests",
        "description": "Lists all DataFormRequests for the given tenant.\n\nRequires: ViewAll on DataForms.",
        "operationId": "ListDataFormRequests",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/DataFormRequestSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by request status (Pending, Submitted, Accepted, Rejected)",
            "schema": {
              "enum": [
                "PendingResponse",
                "ResponseReceived",
                "Cancelled"
              ],
              "type": "string",
              "example": "Pending"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "client-abc"
            }
          },
          {
            "name": "formCode",
            "in": "query",
            "description": "Filter by form code",
            "schema": {
              "type": "string",
              "example": "form-abc"
            }
          },
          {
            "name": "categoryCode",
            "in": "query",
            "description": "Filter by form category code",
            "schema": {
              "type": "string",
              "example": "onboarding"
            }
          },
          {
            "name": "managerCode",
            "in": "query",
            "description": "Filter by client manager user code",
            "schema": {
              "type": "string",
              "example": "USR001"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter by client partner user code",
            "schema": {
              "type": "string",
              "example": "USR002"
            }
          },
          {
            "name": "taskCategoryCode",
            "in": "query",
            "description": "Filter by task category code",
            "schema": {
              "type": "string",
              "example": "CAT001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormRequestDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests/{code}": {
      "get": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Get DataFormRequest",
        "description": "Gets a DataFormRequest for the specified tenant.\n\nRequires: ViewAll on DataForms.",
        "operationId": "GetDataFormRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormRequestDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Update DataFormRequest",
        "description": "Updates a DataFormRequest for the specified tenant.\n\nRequires: Update on DataForms.",
        "operationId": "UpdateDataFormRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataFormRequestDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Delete DataFormRequest",
        "description": "Deletes a DataFormRequest for the specified tenant.\n\nRequires: Delete on DataForms.",
        "operationId": "DeleteDataFormRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests/{code}/answers/{questionCode}/review": {
      "put": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Review DataForm Answer",
        "description": "Accepts or rejects a single answer on a submitted form request. When accepted, applies the value to the client record.\n\nRequires: Update on DataForms.",
        "operationId": "ReviewDataFormAnswer",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "questionCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviewDataFormAnswerRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests/{code}/resend": {
      "put": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Resend DataForm Request",
        "description": "Resends the notification email for a pending form request to the specified recipients. Everyone the form already went to keeps their link and keeps being chased, unless stopChasingOthers is set, which makes these the only recipients.\n\nRequires: ViewAll on Clients and Update on DataForms.",
        "operationId": "ResendDataFormRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResendDataFormRequestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests/{code}/cancel": {
      "put": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Cancel DataForm Request",
        "description": "Cancels a form request still awaiting the client's response. It stops being chased, leaves the client's outstanding forms and its links stop working. Draft answers the client saved are kept, and the linked workflow step is not changed. 400 when the request is no longer awaiting a response.\n\nRequires: Update on DataForms.",
        "operationId": "CancelDataFormRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests/{code}/recipients": {
      "get": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Get DataForm Request Recipients",
        "description": "Returns the email addresses a form request currently counts as its recipients: everyone it was sent to and has not since been withdrawn from. These are the addresses its chases go to.\n\nRequires: ViewAll on DataForms.",
        "operationId": "GetDataFormRequestRecipients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestRecipientsDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests/{code}/reopen": {
      "put": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Reopen DataForm Request",
        "description": "Sends a submitted form request back to the client to complete again. Reuses the same request rather than creating a new one: the previous answers pre-fill the form (except any a reviewer rejected) and the covering message can be replaced.\n\nRequires: ViewAll on Clients and Update on DataForms.",
        "operationId": "ReopenDataFormRequest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReopenDataFormRequestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormRequestDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests/{code}/export/editable-html": {
      "post": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Render DataForm Answers for Editing",
        "description": "Returns the request's answers laid out as a document in the form's export layout, to edit before viewing them as a PDF, saving them to the client's documents or emailing them. Lists the questions the client answered, in form order, as the form reads now. Saves nothing. 400 when the request has no answers.\n\nRequires: ViewAll on DataForms.",
        "operationId": "RenderDataFormExportEditableHtml",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormExportHtmlDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests/{code}/export/preview-pdf": {
      "post": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Preview DataForm Answers PDF",
        "description": "Returns the PDF of the edited answers from the editable-html route, finished with the practice's design theme. The HTML is not parsed as a template. Saves nothing. 400 when the request has no answers.\n\nRequires: ViewAll on DataForms.",
        "operationId": "PreviewDataFormExportPdf",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataFormExportPdfRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-form-requests/{code}/export/document": {
      "post": {
        "tags": [
          "Data Form - Requests"
        ],
        "summary": "Save DataForm Answers to Documents",
        "description": "Saves the PDF of the edited answers from the editable-html route as a document on the request's client, and returns it. The document has no link back to the request. 400 when the request has no answers.\n\nRequires: ViewAll on DataForms and Create on ClientDocuments.",
        "operationId": "SaveDataFormExportDocument",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataFormExportDocumentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          },
          {
            "entity": "ClientDocuments",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms": {
      "get": {
        "tags": [
          "Data Forms"
        ],
        "summary": "List DataForms",
        "description": "Lists all DataForms for the given tenant.\n\nRequires: ViewAll on DataForms.",
        "operationId": "ListDataForms",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/DataFormSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by form status (Draft, Published, Archived)",
            "schema": {
              "enum": [
                "Draft",
                "Published",
                "Archived"
              ],
              "type": "string",
              "example": "Published"
            }
          },
          {
            "name": "customFieldCode",
            "in": "query",
            "description": "Only forms that ask for this custom field, or use it as a section or question condition",
            "schema": {
              "type": "string",
              "example": "favourite_colour"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Create DataForm",
        "description": "Creates a new DataForm for the specified tenant.\n\nRequires: Create on DataForms.",
        "operationId": "CreateDataForm",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDataFormRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/{code}": {
      "get": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Get DataForm",
        "description": "Gets a DataForm for the specified tenant.\n\nRequires: ViewAll on DataForms.",
        "operationId": "GetDataForm",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Update DataForm",
        "description": "Updates a DataForm for the specified tenant.\n\nRequires: Update on DataForms.",
        "operationId": "UpdateDataForm",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDataFormRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Delete DataForm",
        "description": "Deletes a DataForm for the specified tenant.\n\nRequires: Delete on DataForms.",
        "operationId": "DeleteDataForm",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/library": {
      "get": {
        "tags": [
          "Data Forms"
        ],
        "summary": "List Library DataForms",
        "description": "List all DataForms available in the library as templates. Use optional 'search' query parameter to filter by Code, Name, or Description.\n\nRequires: ViewAll on DataForms.",
        "operationId": "ListLibraryDataForms",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DataFormDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/library/{code}": {
      "get": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Get Library DataForm",
        "description": "Get details of a specific DataForm template from the library\n\nRequires: ViewAll on DataForms.",
        "operationId": "GetLibraryDataForm",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/{code}/library-version": {
      "put": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Revert DataForm to Library",
        "description": "Reverts the DataForm to the current library template version, overwriting any local edits. The DataForm's code is preserved so it remains addressable at the same URL. Returns 400 if the DataForm was not imported from the library, or 404 if the DataForm or its source library template no longer exists.\n\nRequires: Update on DataForms.",
        "operationId": "RevertDataFormToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/library/{libraryCode}/create": {
      "post": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Create DataForm from Library",
        "description": "Creates a new DataForm for the tenant based on a library template. Automatically creates the form category if it doesn't exist. Re-imports of the same library item are supported and produce a fresh row with the supplied NameSuffix appended (or auto '(N)' when omitted).\n\nRequires: Create on DataForms.",
        "operationId": "CreateDataFormFromLibrary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "libraryCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportFromLibraryRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/{code}/send": {
      "post": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Send DataForm to Client",
        "description": "Sends a published form to a single client, creating a form request and sending a notification email. When scheduledAt is set, nothing is created now: a scheduled send dispatches it at that time and 202 is returned.\n\nRequires: ViewAll on Clients and Update on DataForms.",
        "operationId": "SendDataFormToClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendDataFormRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormRequestDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/{code}/send-bulk": {
      "post": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Send DataForm to Multiple Clients",
        "description": "Sends a published form to multiple clients in bulk. When scheduledAt is set, nothing is created now: a scheduled send dispatches it at that time and 202 is returned.\n\nRequires: ViewAll on Clients and Update on DataForms.",
        "operationId": "BulkSendDataForm",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkSendDataFormRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "DataForms",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/convert": {
      "post": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Convert Form File",
        "description": "Converts an external form definition file (e.g. Engager .cexp) into Sodium's import format.\n\nRequires: Create on DataForms.",
        "operationId": "ConvertFormFile",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConvertFormFileRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConvertFormFileResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/{code}/client-preview": {
      "post": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Create Client Preview Link",
        "description": "Creates a short-lived (5 min) portal URL for staff to preview the form exactly as a specific client would see it. Access is gated by client visibility restrictions.\n\nRequires: ViewAll on Clients and ViewAll on DataForms.",
        "operationId": "CreateDataFormClientPreview",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientPreviewDataFormRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateDataFormPreviewTokenResult"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/{code}/preview": {
      "get": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Preview DataForm",
        "description": "Returns the form structure as the client would see it, for preview purposes.\n\nRequires: ViewAll on DataForms.",
        "operationId": "PreviewDataForm",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataFormPreviewDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/{code}/export-template": {
      "post": {
        "tags": [
          "Data Forms"
        ],
        "summary": "Create DataForm Answers Template",
        "description": "Creates a Form Answers template for the form, written out from it: its sections as headings and every question's prompt with its answer token ({{ Form.Answers.<tokenName> }}), to rearrange into a letter or report. Questions without a token name get one from their prompt first. The template is not made the form's export layout: set exportDocumentTemplateCode on the form for that.\n\nRequires: ViewAll on DataForms and Create on Templates.",
        "operationId": "CreateDataFormAnswersTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentTemplateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DataForms",
            "permission": "ViewAll"
          },
          {
            "entity": "Templates",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/data-forms/{code}/answer-tokens": {
      "get": {
        "tags": [
          "Data Forms"
        ],
        "summary": "List DataForm Answer Tokens",
        "description": "Lists the form's questions with their token names, in section and question order, for a Form Answers template's token picker: each answer is {{ Form.Answers.<tokenName> }}. Questions without a token name get one from their prompt first.\n\nRequires at least one of: ViewAll on DataForms or ViewAll on Templates.",
        "operationId": "ListDataFormAnswerTokens",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DataFormAnswerTokenDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "DataForms",
              "permission": "ViewAll"
            },
            {
              "entity": "Templates",
              "permission": "ViewAll"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/designthemes/{designThemeCode}/backgroundimages": {
      "get": {
        "tags": [
          "Design Theme - Background Images"
        ],
        "summary": "List Background Images",
        "description": "Returns all background images configured on the specified design theme, ordered by sort order.\n\nRequires: ViewAll on DesignThemes.",
        "operationId": "ListDesignThemeBackgroundImages",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "designThemeCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BackgroundImageDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Design Theme - Background Images"
        ],
        "summary": "Add Background Image",
        "description": "Adds a new background image to the specified design theme.\n\nRequires: Update on DesignThemes.",
        "operationId": "AddDesignThemeBackgroundImage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "designThemeCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BackgroundImageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BackgroundImageDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/designthemes/{designThemeCode}/backgroundimages/{imageCode}": {
      "put": {
        "tags": [
          "Design Theme - Background Images"
        ],
        "summary": "Update Background Image",
        "description": "Updates an existing background image on the specified design theme.\n\nRequires: Update on DesignThemes.",
        "operationId": "UpdateDesignThemeBackgroundImage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "designThemeCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "imageCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BackgroundImageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BackgroundImageDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Design Theme - Background Images"
        ],
        "summary": "Delete Background Image",
        "description": "Removes a background image from the specified design theme.\n\nRequires: Update on DesignThemes.",
        "operationId": "DeleteDesignThemeBackgroundImage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "designThemeCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "imageCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/designthemes": {
      "get": {
        "tags": [
          "Design Themes"
        ],
        "summary": "List DesignThemes",
        "description": "Lists all DesignThemes for the given tenant.\n\nRequires: ViewAll on DesignThemes.",
        "operationId": "ListDesignThemes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/DesignThemeSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesignThemeDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Design Themes"
        ],
        "summary": "Create DesignTheme",
        "description": "Creates a new DesignTheme for the specified tenant.\n\nRequires: Create on DesignThemes.",
        "operationId": "CreateDesignTheme",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDesignThemeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesignThemeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/designthemes/{code}": {
      "get": {
        "tags": [
          "Design Themes"
        ],
        "summary": "Get DesignTheme",
        "description": "Gets a DesignTheme for the specified tenant.\n\nRequires: ViewAll on DesignThemes.",
        "operationId": "GetDesignTheme",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesignThemeDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Design Themes"
        ],
        "summary": "Update DesignTheme",
        "description": "Updates a DesignTheme for the specified tenant.\n\nRequires: Update on DesignThemes.",
        "operationId": "UpdateDesignTheme",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDesignThemeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesignThemeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Design Themes"
        ],
        "summary": "Delete DesignTheme",
        "description": "Deletes a DesignTheme for the specified tenant.\n\nRequires: Delete on DesignThemes.",
        "operationId": "DeleteDesignTheme",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/designthemes/default": {
      "get": {
        "tags": [
          "Design Themes"
        ],
        "summary": "Get Default Design Theme",
        "description": "Returns the default design theme for the specified tenant.\n\nRequires: ViewAll on DesignThemes.",
        "operationId": "GetDefaultDesignTheme",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesignThemeDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/designthemes/{code}/css": {
      "get": {
        "tags": [
          "Design Themes"
        ],
        "summary": "Get Design Theme CSS",
        "description": "Returns the generated CSS for the specified design theme.\n\nRequires: ViewAll on DesignThemes.",
        "operationId": "GetDesignThemeCSS",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "selector",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "suppressPageMargins",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/css": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/designthemes/default/css": {
      "get": {
        "tags": [
          "Design Themes"
        ],
        "summary": "Get Default Design Theme CSS",
        "description": "Returns the generated CSS for the default design theme.\n\nRequires: ViewAll on DesignThemes.",
        "operationId": "GetDefaultDesignThemeCSS",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "selector",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "suppressPageMargins",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/css": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/direct-debit/payers": {
      "get": {
        "tags": [
          "DirectDebit"
        ],
        "summary": "List DirectDebit Payers",
        "description": "Lists all payers (customers) from the direct debit platform\n\nRequires: ViewAll on Clients.",
        "operationId": "GetDirectDebitPayers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PayerDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/direct-debit/mandates": {
      "get": {
        "tags": [
          "DirectDebit"
        ],
        "summary": "List DirectDebit Mandates",
        "description": "Lists mandates from the direct debit platform for a specific payer. Requires payerId.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetDirectDebitMandates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "payerId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MandateDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/direct-debit/mandates/{mandateId}": {
      "get": {
        "tags": [
          "DirectDebit"
        ],
        "summary": "Get DirectDebit Mandate",
        "description": "Gets a specific mandate to check its status\n\nRequires: ViewAll on Clients.",
        "operationId": "GetDirectDebitMandateById",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "mandateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MandateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/direct-debit/setup/send-email": {
      "post": {
        "tags": [
          "DirectDebit"
        ],
        "summary": "Send Direct Debit Setup Email",
        "description": "Sends an email to the client asking them to complete the Direct Debit setup process. Includes a {Url} for them to visit. The ContentBlock for the email is set in the DirectDebitSettings\n\nRequires: ViewAll on Clients and Update on Clients.",
        "operationId": "SendDirectDebitSetupEmail",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendDirectDebitSetupEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/direct-debit/setup/callback": {
      "get": {
        "tags": [
          "DirectDebit"
        ],
        "summary": "Complete Direct Debit Setup",
        "description": "Callback endpoint for completing direct debit mandate setup after customer authorization. The DirectDebit provider will redirect the user here after they set up a mandate. We will then redirect the user to the URl provided as the callbackUrl in the initial SendDirectDebitSetupEmailRequest",
        "operationId": "CompleteDirectDebitSetup",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/tenants/{tenant}/direct-debit/settings": {
      "get": {
        "tags": [
          "DirectDebit"
        ],
        "summary": "Get Direct Debit Settings",
        "description": "Returns the direct debit settings for the specified tenant\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetDirectDebitSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DirectDebitSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "DirectDebit"
        ],
        "summary": "Update Direct Debit Settings",
        "description": "Updates the direct debit settings for the specified tenant\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateDirectDebitSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDirectDebitSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DirectDebitSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-templates": {
      "get": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "List DocumentTemplates",
        "description": "Lists all DocumentTemplates for the given tenant.\n\nRequires: ViewAll on Templates.",
        "operationId": "ListDocumentTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/DocumentTemplateSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "type",
            "in": "query",
            "description": "Filter by template type",
            "schema": {
              "enum": [
                "EngagementLetter",
                "Proposal",
                "AdHoc",
                "FormAnswers"
              ],
              "type": "string",
              "example": "EngagementLetter"
            }
          },
          {
            "name": "isActive",
            "in": "query",
            "description": "Filter by active status (true = active only, false = inactive only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across template code and name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "engagement"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentTemplateDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Create DocumentTemplate",
        "description": "Creates a new DocumentTemplate for the specified tenant.\n\nRequires: Create on Templates.",
        "operationId": "CreateDocumentTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocumentTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-templates/{code}": {
      "get": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Get DocumentTemplate",
        "description": "Gets a DocumentTemplate for the specified tenant.\n\nRequires: ViewAll on Templates.",
        "operationId": "GetDocumentTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentTemplateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Update DocumentTemplate",
        "description": "Updates a DocumentTemplate for the specified tenant.\n\nRequires: Update on Templates.",
        "operationId": "UpdateDocumentTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Delete DocumentTemplate",
        "description": "Deletes a DocumentTemplate for the specified tenant.\n\nRequires: Delete on Templates.",
        "operationId": "DeleteDocumentTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-templates/library": {
      "get": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "List Library DocumentTemplates",
        "description": "List all DocumentTemplates available in the library as templates. Use optional 'search' query parameter to filter by Code, Name, or Description.\n\nRequires: ViewAll on Templates.",
        "operationId": "ListLibraryDocumentTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DocumentTemplateDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-templates/library/{code}": {
      "get": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Get Library DocumentTemplate",
        "description": "Get details of a specific DocumentTemplate template from the library\n\nRequires: ViewAll on Templates.",
        "operationId": "GetLibraryDocumentTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentTemplateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-templates/{code}/library-version": {
      "put": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Revert DocumentTemplate to Library",
        "description": "Reverts the DocumentTemplate to the current library template version, overwriting any local edits. The DocumentTemplate's code is preserved so it remains addressable at the same URL. Returns 400 if the DocumentTemplate was not imported from the library, or 404 if the DocumentTemplate or its source library template no longer exists.\n\nRequires: Update on Templates.",
        "operationId": "RevertDocumentTemplateToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-templates/{code}/render": {
      "post": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Render DocumentTemplate as PDF",
        "description": "Renders a document template with the provided data to PDF format.\n\nThe template receives the TemplateVariables data structure from the request.\nAll properties are optional and accessible via Liquid syntax (e.g., {{ PrimaryContact.FirstName }})\n\n**Example request:**\n```json\nPOST /tenants/acme/document-templates/engagement-letter-standard/render\n{\n  \"designThemeCode\": \"professional-blue\",\n  \"data\": {\n    \"title\": \"Engagement Letter\",\n    \"client\": {\n      \"primaryContact\": { \"firstName\": \"John\", \"lastName\": \"Doe\" },\n      \"partner\": { \"name\": \"Jane Smith\", \"email\": \"jane@example.com\" }\n    },\n    \"practice\": {\n      \"address\": \"123 Main St\",\n      \"email\": \"info@practice.com\",\n      \"telephone\": \"555-1234\"\n    }\n  }\n}\n```\n\nRequires: ViewAll on Templates.",
        "operationId": "RenderDocumentTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderDocumentTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-templates/library/{libraryCode}/import": {
      "post": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Import from Library",
        "description": "Imports a document template from the library, creating any associated custom tokens that don't already exist. Re-imports of the same library item are supported and produce a fresh row with the supplied NameSuffix appended (or auto '(N)' when omitted).\n\nRequires: Create on Templates.",
        "operationId": "ImportDocumentTemplateFromLibrary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "libraryCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportFromLibraryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentTemplateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-templates/{code}/custom-tokens": {
      "get": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Get Custom Tokens",
        "description": "Extracts custom token names from a document template's body HTML and the content blocks it reaches, excluding standard template variables. Pass contentBlockCodes for blocks the render adds that the template doesn't name, such as a proposal's service schedules.\n\nRequires: ViewAll on Templates.",
        "operationId": "GetDocumentTemplateCustomTokens",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "clientCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "contentBlockCodes",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DocumentTemplateTokenInfo"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Templates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-templates/validate": {
      "post": {
        "tags": [
          "Document - Templates"
        ],
        "summary": "Validate Template Syntax",
        "description": "Parses a Liquid template fragment under the real rendering engine and returns any syntax error with its location. Does not render or require data.\n\nOpen to any signed-in user of the tenant: Stateless syntax check of a template fragment; touches no stored data",
        "operationId": "ValidateTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidateTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateValidationResultDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Stateless syntax check of a template fragment; touches no stored data"
      }
    },
    "/tenants/{tenant}/documentrequests": {
      "get": {
        "tags": [
          "Document Requests"
        ],
        "summary": "List Document Requests",
        "description": "Returns a paged list of document requests across all clients.\n\nRequires: ViewAll on DocumentRequests.",
        "operationId": "ListAllDocumentRequests",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/DocumentRequestSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by request status (Draft, Open, Submitted, Accepted, Rejected, Cancelled)",
            "schema": {
              "enum": [
                "Draft",
                "Open",
                "Submitted",
                "Accepted",
                "Rejected",
                "Cancelled"
              ],
              "type": "string",
              "example": "Open"
            }
          },
          {
            "name": "needsReview",
            "in": "query",
            "description": "true: only requests with a submission or answered items to review; false: only those without",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "managerCode",
            "in": "query",
            "description": "Filter by client manager user code",
            "schema": {
              "type": "string",
              "example": "USR001"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter by client partner user code",
            "schema": {
              "type": "string",
              "example": "USR002"
            }
          },
          {
            "name": "taskCategoryCode",
            "in": "query",
            "description": "Filter by task category code",
            "schema": {
              "type": "string",
              "example": "CAT001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across request title and description (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "tax returns"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-request-item-lists": {
      "get": {
        "tags": [
          "Document Requests - Saved Lists"
        ],
        "summary": "List DocumentRequestItemLists",
        "description": "Lists all DocumentRequestItemLists for the given tenant.\n\nRequires: ViewAll on DocumentRequests.",
        "operationId": "ListDocumentRequestItemLists",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/DocumentRequestItemListSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "isActive",
            "in": "query",
            "description": "Filter by whether the list is active (offered by \"Use a saved list\")",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestItemListDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Document Requests - Saved Lists"
        ],
        "summary": "Create DocumentRequestItemList",
        "description": "Creates a new DocumentRequestItemList for the specified tenant.\n\nRequires: Create on DocumentRequests.",
        "operationId": "CreateDocumentRequestItemList",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocumentRequestItemListRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestItemListDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-request-item-lists/{code}": {
      "get": {
        "tags": [
          "Document Requests - Saved Lists"
        ],
        "summary": "Get DocumentRequestItemList",
        "description": "Gets a DocumentRequestItemList for the specified tenant.\n\nRequires: ViewAll on DocumentRequests.",
        "operationId": "GetDocumentRequestItemList",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestItemListDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Document Requests - Saved Lists"
        ],
        "summary": "Update DocumentRequestItemList",
        "description": "Updates a DocumentRequestItemList for the specified tenant.\n\nRequires: Update on DocumentRequests.",
        "operationId": "UpdateDocumentRequestItemList",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentRequestItemListRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentRequestItemListDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Document Requests - Saved Lists"
        ],
        "summary": "Delete DocumentRequestItemList",
        "description": "Deletes a DocumentRequestItemList for the specified tenant.\n\nRequires: Delete on DocumentRequests.",
        "operationId": "DeleteDocumentRequestItemList",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DocumentRequests",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-categories": {
      "get": {
        "tags": [
          "Documents - Categories"
        ],
        "summary": "List DocumentCategories",
        "description": "Lists all DocumentCategories for the given tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "ListDocumentCategories",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/DocumentCategorySortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentCategoryDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Documents - Categories"
        ],
        "summary": "Create DocumentCategory",
        "description": "Creates a new DocumentCategory for the specified tenant.\n\nRequires: Create on PracticeDetails.",
        "operationId": "CreateDocumentCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocumentCategoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentCategoryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-categories/{code}": {
      "get": {
        "tags": [
          "Documents - Categories"
        ],
        "summary": "Get DocumentCategory",
        "description": "Gets a DocumentCategory for the specified tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetDocumentCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentCategoryDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Documents - Categories"
        ],
        "summary": "Update DocumentCategory",
        "description": "Updates a DocumentCategory for the specified tenant.\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateDocumentCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentCategoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentCategoryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Documents - Categories"
        ],
        "summary": "Delete DocumentCategory",
        "description": "Deletes a DocumentCategory for the specified tenant.\n\nRequires: Delete on PracticeDetails.",
        "operationId": "DeleteDocumentCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-filing-settings": {
      "get": {
        "tags": [
          "Documents - Filing"
        ],
        "summary": "Get document filing settings",
        "description": "Returns where the practice's client documents are filed: each client's folder name in document storage, and each kind of document's storage subfolder and client portal folder\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "GetDocumentFilingSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentFilingSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Documents - Filing"
        ],
        "summary": "Update document filing settings",
        "description": "Replaces where the practice's client documents are filed. Returns 400 when a path's tokens do not parse\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "UpdateDocumentFilingSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentFilingSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentFilingSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/document-filing-settings/{source}": {
      "get": {
        "tags": [
          "Documents - Filing"
        ],
        "summary": "Get Document Filing Setting for Source",
        "description": "Where the practice files one kind of document, as configured with its tokens: read-only, saved through the PUT on the whole settings. Used as the default by settings that are themselves templates (a workflow step, an information request). The portal path is the storage path when the practice files them the same.\n\nOpen to any signed-in user of the tenant: Where the practice files documents, shown wherever staff choose a folder for one",
        "operationId": "GetDocumentFilingSettingForSource",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "source",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/DocumentFilingSource"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentFilingDefaultDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Where the practice files documents, shown wherever staff choose a folder for one"
      }
    },
    "/tenants/{tenant}/email-broadcasts": {
      "get": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "List Email Broadcasts",
        "description": "Returns a paged list of email broadcasts for the tenant, newest first. Filter by status.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "ListEmailBroadcasts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/EmailBroadcastSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by broadcast status (Draft, Queued, Sending, Completed, Failed, Cancelled)",
            "schema": {
              "enum": [
                "Draft",
                "Queued",
                "Sending",
                "Completed",
                "Failed",
                "Cancelled",
                "Scheduled"
              ],
              "type": "string",
              "example": "Draft"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Create Email Broadcast",
        "description": "Creates a draft email broadcast. Content is either a content block (category: Email) or an inline subject and body with Liquid tokens — not both. Recipient selection combines an optional client filter with hand-picked additions and exclusions. Requires the tenant to have connected at least one of their own send-enabled email accounts — broadcasts cannot be sent from the shared system mailbox.\n\nRequires: Create on EmailBroadcasts.",
        "operationId": "CreateEmailBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEmailBroadcastRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-broadcasts/audience-summary": {
      "post": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Summarise Broadcast Audience",
        "description": "Evaluates a client selection (saved view or inline filter, plus additions and exclusions) and returns how many clients it resolves to and how many of those have not opted in to email contact. When a To-recipient configuration is included, also counts clients with no resolvable email address. Read-only — used by the wizard before a draft exists.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "GetEmailBroadcastAudienceSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailBroadcastAudienceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastAudienceSummaryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-broadcasts/{code}": {
      "get": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Get Email Broadcast",
        "description": "Returns a single email broadcast including its status and progress counters.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "GetEmailBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Update Email Broadcast",
        "description": "Updates a draft email broadcast (full replacement). Once queued, a broadcast is immutable — only cancel is available.\n\nRequires: Update on EmailBroadcasts.",
        "operationId": "UpdateEmailBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEmailBroadcastRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Delete Email Broadcast",
        "description": "Deletes a draft email broadcast. Sent broadcasts cannot be deleted — they are the audit record of what was sent.\n\nRequires: Delete on EmailBroadcasts.",
        "operationId": "DeleteEmailBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-broadcasts/{code}/recipients": {
      "get": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "List Broadcast Recipients",
        "description": "Returns the paged recipient list, optionally filtered by client name via the search parameter. For drafts the recipients are resolved live (pre-send view including skipped clients with reasons, e.g. no resolvable contact or email preference not set); after sending, the stored snapshot with per-client delivery status is returned.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "GetEmailBroadcastRecipients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/EmailBroadcastRecipientSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastRecipientDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-broadcasts/{code}/repeated-addresses": {
      "get": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "List Repeated Broadcast Addresses",
        "description": "For a draft, lists the contact addresses that are on more than one selected client, how many copies sending once per address would drop, and whether the content is personalised per client. Team members and the broadcast's fixed addresses are never counted.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "GetEmailBroadcastRepeatedAddresses",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastRepeatedAddressesDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-broadcasts/{code}/preview/{clientCode}": {
      "get": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Preview Broadcast Email",
        "description": "Renders the broadcast subject and body for the sample client identified by clientCode with Liquid tokens resolved and tenant branding applied, plus the client's resolved recipients.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "PreviewEmailBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-broadcasts/{code}/test": {
      "post": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Send Test Email",
        "description": "Renders the broadcast for the sample client in the request body and sends it to the current user's own email address only.\n\nRequires: Update on EmailBroadcasts.",
        "operationId": "SendTestEmailBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestEmailBroadcastRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-broadcasts/{code}/send": {
      "post": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Send Email Broadcast",
        "description": "Sends a draft broadcast: re-evaluates the client selection, snapshots each client's resolved recipients (the audit record), marks the broadcast Queued and enqueues background processing. Poll the broadcast for progress and the recipients endpoint for the per-client delivery log. When the optional body sets scheduledAt, the broadcast is not sent now: it moves to Scheduled status and is dispatched at that time — recipients are resolved and snapshotted at dispatch, not schedule time.\n\nRequires: Update on EmailBroadcasts.",
        "operationId": "SendEmailBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendEmailBroadcastRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-broadcasts/{code}/revert-to-draft": {
      "post": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Revert Broadcast to Draft",
        "description": "Reverts a scheduled broadcast to Draft by cancelling its pending scheduled send. The broadcast becomes editable again and will not go out until it is sent or re-scheduled.\n\nRequires: Update on EmailBroadcasts.",
        "operationId": "RevertEmailBroadcastToDraft",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-broadcasts/{code}/cancel": {
      "post": {
        "tags": [
          "Email - Broadcasts"
        ],
        "summary": "Cancel Email Broadcast",
        "description": "Cancels a queued or sending broadcast. Recipients not yet processed remain Pending and are not sent.\n\nRequires: Update on EmailBroadcasts.",
        "operationId": "CancelEmailBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs": {
      "get": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "List Email Configs",
        "description": "Returns a paginated list of email configurations the current user can access (owned or shared). EmailConnections admins see all configurations including other users' private ones.\n\nRequires: ViewAll on EmailConnections.",
        "operationId": "ListEmailConfigs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/EmailConfigSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "isDefault",
            "in": "query",
            "description": "Filter by default status",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "isSendShared",
            "in": "query",
            "description": "Filter by send-shared status",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "readSharing",
            "in": "query",
            "description": "Filter by read-sharing mode (Private, Everyone, Selected)",
            "schema": {
              "enum": [
                "Private",
                "Everyone",
                "Selected"
              ],
              "type": "string",
              "example": "Everyone"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by configuration lifecycle status",
            "schema": {
              "enum": [
                "PendingOAuthSetup",
                "Active",
                "OAuthFailed",
                "Deleted",
                "OAuthExpired",
                "ConnectionError",
                "Deleting"
              ],
              "type": "string",
              "example": "Active"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailConfigDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Create Email Config",
        "description": "Creates a new email configuration. For SMTP: provide SmtpSettings. For OAuth (Microsoft365/Google): provide OAuthSettings with returnUrl - response includes authorisationUrl to redirect user to. The first connection must be created with IsDefault true (admin only); standard users can only add their own connection once an Active practice default exists. If IsDefault is true, IsSendShared must also be true.\n\nRequires: Create on EmailConnections.",
        "operationId": "CreateEmailConfig",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEmailConfigRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailConfigDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}": {
      "get": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Get Email Config",
        "description": "Returns a single email configuration including provider details (SMTP settings, OAuth status). User must be the owner or an admin, or the config must be shared.\n\nRequires: ViewAll on EmailConnections.",
        "operationId": "GetEmailConfig",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailConfigDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Update Email Config",
        "description": "Updates an existing email configuration. Supports updating provider settings (SMTP or OAuth), display name (FromName), and flags (IsDefault, IsSendShared, IsReadShared). User must be the owner or an admin. Only admins can change IsDefault. Only the owner can change IsReadShared or ReadEnabled — including admins.\n\nRequires: Update on EmailConnections.",
        "operationId": "UpdateEmailConfig",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEmailConfigRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailConfigDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Delete Email Config",
        "description": "Deletes an email configuration. Cannot delete the tenant's default config unless it is the only one remaining. User must be the connection's owner or an admin.\n\nRequires: Delete on EmailConnections.",
        "operationId": "DeleteEmailConfig",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/test": {
      "post": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Test Email Config",
        "description": "Sends a test email using the specified configuration to verify it is working correctly. User must be the connection's owner or an admin.\n\nRequires: Update on EmailConnections.",
        "operationId": "TestEmailConfig",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestEmailResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/reconnect": {
      "post": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Reconnect OAuth email configuration",
        "description": "Generates a fresh OAuth authorisation URL for reconnecting an expired or incorrectly-connected email configuration. Only works for OAuth providers (Microsoft365, Google) — returns 400 for SMTP. Sets the configuration status to PendingOAuthSetup. After the user completes the OAuth flow, the configuration status returns to Active automatically. User must be the connection's owner or an admin.\n\nRequires: Update on EmailConnections.",
        "operationId": "ReconnectEmailConfigOAuth",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReconnectOAuthRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReconnectOAuthResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/personal-signature": {
      "put": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Update Personal Signature",
        "description": "Sets the current user's own signature on a mailbox they can send from (they own it, or it is send-shared). Their composed emails use it instead of the mailbox's signature, which still applies to everyone else and to emails Sodium sends automatically. A null or blank signature removes it.\n\nRequires: ViewAll on EmailConnections.",
        "operationId": "UpdateEmailConfigPersonalSignature",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePersonalSignatureRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/new-mail-alert": {
      "put": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Update New Mail Alert",
        "description": "Sets which new emails in a mailbox the current user is told about, in the bell and as a desktop notification: every new email, or only those on conversations assigned to them or to nobody. Needs triage on the mailbox and full read access to it. A null scope switches the alert off.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "UpdateEmailConfigNewMailAlert",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateNewMailAlertRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/ungrouped-senders": {
      "get": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Get Ungrouped Senders",
        "description": "Returns the addresses and domains whose emails each arrive as a conversation of their own instead of joining the thread Outlook or Gmail puts them in. User must be the connection's owner or an admin.\n\nRequires: ViewAll on EmailConnections.",
        "operationId": "GetEmailConfigUngroupedSenders",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UngroupedSendersDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Update Ungrouped Senders",
        "description": "Replaces the addresses and domains whose emails each arrive as a conversation of their own (a domain covers its subdomains; an empty list clears it). Emails already in the mailbox from an address or domain added are split into conversations of their own too; splitEmailCount says how many. A conversation that loses emails keeps its status, links, comments and tasks. The connection must receive emails. User must be the connection's owner or an admin.\n\nRequires: Update on EmailConnections.",
        "operationId": "UpdateEmailConfigUngroupedSenders",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UngroupedSendersDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UngroupedSendersDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Update"
          }
        ]
      },
      "post": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Add Ungrouped Sender",
        "description": "Adds one address or domain to the mailbox's ungrouped senders and splits its emails already in the mailbox into conversations of their own; splitEmailCount says how many. Adding one already on the list splits any of its emails still grouped. The connection must receive emails. User must be the connection's owner or an admin.\n\nRequires: Update on EmailConnections.",
        "operationId": "AddEmailConfigUngroupedSender",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddUngroupedSenderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UngroupedSendersDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/ungrouped-senders/preview": {
      "get": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Preview Ungrouped Sender",
        "description": "Counts the emails already in the mailbox that adding this address or domain to its ungrouped senders would split, without changing anything. The connection must receive emails. User must be the connection's owner or an admin.\n\nRequires: ViewAll on EmailConnections.",
        "operationId": "PreviewEmailConfigUngroupedSender",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "sender",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UngroupedSenderPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/share-rules": {
      "get": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "List Share Rules",
        "description": "Returns every rule on this mailbox with isExclusion on each row. Rules with isExclusion false decide which emails colleagues may read when the mailbox shares selected emails; rules with isExclusion true hide what they match from everyone but the owner, in both sharing modes. Only the user who set up the connection can list or change them.\n\nRequires: ViewAll on EmailConnections.",
        "operationId": "ListEmailConfigShareRules",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MailboxShareRuleDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Add Share Rule",
        "description": "Adds an address, domain, conversation, folder or message rule. With isExclusion false it shares what it matches; with isExclusion true it hides what it matches from everyone but the owner, in both sharing modes (exclusions win). Addresses and domains are lowercased; a folder rule must name a folder on this mailbox; a message rule must name a message in it. Adding a rule that already exists returns the existing rule, and adding the same kind and value with the other flag flips it. The connection must receive emails; it need not already be sharing selected emails.\n\nRequires: Update on EmailConnections.",
        "operationId": "CreateEmailConfigShareRule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMailboxShareRuleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxShareRuleDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/share-rules/{ruleId}": {
      "delete": {
        "tags": [
          "Email - Configs"
        ],
        "summary": "Delete Share Rule",
        "description": "Removes a rule. A removed share stops its emails being visible to colleagues at once; a removed exclusion makes its emails visible again wherever another rule or the sharing mode shares them.\n\nRequires: Update on EmailConnections.",
        "operationId": "DeleteEmailConfigShareRule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-history": {
      "get": {
        "tags": [
          "Email - History"
        ],
        "summary": "List Email History",
        "description": "Returns a paginated list of emails sent for the tenant. Supports filtering by status, date range, search, and metadata fields. Metadata filters use the format metadataParam=key=value (e.g., metadataParam=entityType=Proposal).\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "ListEmails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/EmailSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by email status (Queued, Sending, Sent, Delivered, Failed, Bounced)",
            "schema": {
              "enum": [
                "Queued",
                "Processing",
                "Sent",
                "Failed",
                "Cancelled"
              ],
              "type": "string",
              "example": "Sent"
            }
          },
          {
            "name": "fromDate",
            "in": "query",
            "description": "Filter by emails created on or after this date (ISO 8601 format)",
            "schema": {
              "type": "string",
              "example": "2025-01-01"
            }
          },
          {
            "name": "toDate",
            "in": "query",
            "description": "Filter by emails created on or before this date (ISO 8601 format)",
            "schema": {
              "type": "string",
              "example": "2025-12-31"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search in email subject and recipient email address",
            "schema": {
              "type": "string",
              "example": "invoice"
            }
          },
          {
            "name": "metadataParam",
            "in": "query",
            "description": "Filter by custom metadata stored with the email. Each value should be in key=value format. Can specify multiple (e.g., metadataParam=entityType=Proposal&metadataParam=entityId=123)",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"entityType=Proposal\", \"entityId=123\", \"color=red\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListEmailsResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-history/{emailId}": {
      "get": {
        "tags": [
          "Email - History"
        ],
        "summary": "Get Email Details",
        "description": "Returns the full details of a specific email by its ID, including recipients, attachments, and delivery status.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetEmailDetails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "emailId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetMessageResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/mailbox/folders": {
      "get": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "List Folders",
        "description": "Returns the full folder/label set across the tenant's read-enabled mailbox configurations. When configCode query param is omitted, returns folders for every accessible config (owned or shared). When configCode is provided (repeatable), narrows to those configs. Set systemFoldersOnly=true to return only provider-system folders (Inbox/Sent/Drafts/Archive/Junk/Trash/Outbox/GmailPromotionalCategory) — combined-mailbox views use this. Each folder includes per-folder total and unread counts.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "ListMailboxFolders",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "configCode",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "x-order": 400
          },
          {
            "name": "systemFoldersOnly",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalMailboxFolderDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/mailbox/conversations": {
      "get": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "List Conversations",
        "description": "Returns a paginated list of email conversations (threads). When configCode query param is omitted, searches across mailbox configurations the current user can access (owned or shared). When configCode is provided, scopes to that single configuration. Supports filtering by direction, participant email/domain, include/exclude message IDs, and search. folderScope=AllExceptJunk searches every folder but Junk, instead of one folder. Email triage: view, status, open, assignee (a user code or \"me\") and unassigned narrow the list to mailboxes with triage on; every conversation of such a mailbox carries triageStatusCode, triageAssigneeCode and triageIsMatched (true Matched, false Other, null Unmatched). Pagination defaults: offset=0, limit=10, max limit=50.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "ListMailboxConversations",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/MailboxConversationSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "folderScope",
            "in": "query",
            "description": "A named folder set across every mailbox in scope: Received (received mail in any folder but Sent) or AllExceptJunk (every folder but Junk, for searching the whole mailbox). Mutually exclusive with folderUniqueId and systemFolderType. A triage view, status or assignee filter lists the Inbox instead.",
            "schema": {
              "enum": [
                "Received",
                "AllExceptJunk"
              ],
              "type": "string",
              "example": "AllExceptJunk"
            }
          },
          {
            "name": "view",
            "in": "query",
            "description": "Only conversations in this triage view (Matched, Unmatched or Other). Unmatched includes conversations not classified yet. Mailboxes with triage off are left out.",
            "schema": {
              "enum": [
                "Matched",
                "Unmatched",
                "Other"
              ],
              "type": "string",
              "example": "Unmatched"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Only conversations whose triage status is one of these codes (repeatable). Mailboxes with triage off are left out.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"new\", \"in_progress\" ]"
            }
          },
          {
            "name": "open",
            "in": "query",
            "description": "true: only conversations not at a Done status. Mailboxes with triage off are left out.",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "assignee",
            "in": "query",
            "description": "Only conversations assigned to this tenant user code, or \"me\" for the caller. Not with unassigned. Mailboxes with triage off are left out.",
            "schema": {
              "type": "string",
              "example": "me"
            }
          },
          {
            "name": "unassigned",
            "in": "query",
            "description": "true: only conversations assigned to nobody. Not with assignee. Mailboxes with triage off are left out.",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "configCode",
            "in": "query",
            "description": "Filter by configuration code (GUID, repeatable). Omit to search across all read-enabled configs.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"895c888f-c2ba-4c86-9d91-1eff95045e6a\" ]"
            }
          },
          {
            "name": "direction",
            "in": "query",
            "description": "Filter by email direction (Inbound = received emails, Outbound = sent emails)",
            "schema": {
              "enum": [
                "Inbound",
                "Outbound"
              ],
              "type": "string",
              "example": "Inbound"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search by subject, sender email/name or the start of the body (the snippet)",
            "schema": {
              "type": "string",
              "example": "invoice"
            }
          },
          {
            "name": "participantEmail",
            "in": "query",
            "description": "Filter by participant email address - matches From, To, and Cc fields. Can specify multiple (OR logic).",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"john@example.com\", \"jane@example.com\" ]"
            }
          },
          {
            "name": "participantDomain",
            "in": "query",
            "description": "Filter by participant email domain - matches From, To, and Cc fields. Can specify multiple (OR logic).",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"example.com\", \"acme.org\" ]"
            }
          },
          {
            "name": "includeMessageId",
            "in": "query",
            "description": "Force-include specific message UniqueIds regardless of participant filters (repeatable).",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"3b39ae56-f6f4-4e6c-82c9-661a5cc366ec\" ]"
            }
          },
          {
            "name": "excludeMessageId",
            "in": "query",
            "description": "Force-exclude specific message UniqueIds even if they match participant filters (repeatable).",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"3b39ae56-f6f4-4e6c-82c9-661a5cc366ec\" ]"
            }
          },
          {
            "name": "folderUniqueId",
            "in": "query",
            "description": "Filter to messages whose junction maps to any of these folder uniqueIds (repeatable, OR logic). Single-mailbox mode. Mutually exclusive with systemFolderType.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"3b39ae56-f6f4-4e6c-82c9-661a5cc366ec\" ]"
            }
          },
          {
            "name": "systemFolderType",
            "in": "query",
            "description": "Filter to messages in folders of the given system type (Inbox/Sent/Drafts/...). Combined-mailbox mode. Mutually exclusive with folderUniqueId.",
            "schema": {
              "enum": [
                "None",
                "Inbox",
                "Sent",
                "Drafts",
                "Junk",
                "Trash",
                "Archive",
                "Outbox",
                "GmailCategory",
                "GmailPromotionalCategory",
                "OutsideFolderTree"
              ],
              "type": "string",
              "example": "Inbox"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxThreadSummaryDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/mailbox/messages": {
      "get": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "List Messages",
        "description": "Returns a paginated flat list of individual messages (not grouped by thread). When configCode query param is omitted, searches across mailbox configurations the current user can access (owned or shared). When configCode is provided, scopes to that single configuration. Supports filtering by direction, participant email/domain, include/exclude message IDs, and search. Pagination defaults: offset=0, limit=10, max limit=50.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "ListMailboxMessages",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/MailboxMessageSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "configCode",
            "in": "query",
            "description": "Filter by configuration code (GUID, repeatable). Omit to search across all read-enabled configs.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"895c888f-c2ba-4c86-9d91-1eff95045e6a\" ]"
            }
          },
          {
            "name": "direction",
            "in": "query",
            "description": "Filter by email direction (Inbound = received emails, Outbound = sent emails)",
            "schema": {
              "enum": [
                "Inbound",
                "Outbound"
              ],
              "type": "string",
              "example": "Inbound"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search by subject, sender email/name or the start of the body (the snippet)",
            "schema": {
              "type": "string",
              "example": "invoice"
            }
          },
          {
            "name": "participantEmail",
            "in": "query",
            "description": "Filter by participant email address - matches From, To, and Cc fields. Can specify multiple (OR logic).",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"john@example.com\", \"jane@example.com\" ]"
            }
          },
          {
            "name": "participantDomain",
            "in": "query",
            "description": "Filter by participant email domain - matches From, To, and Cc fields. Can specify multiple (OR logic).",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"example.com\", \"acme.org\" ]"
            }
          },
          {
            "name": "includeMessageId",
            "in": "query",
            "description": "Force-include specific message UniqueIds regardless of participant filters (repeatable).",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"3b39ae56-f6f4-4e6c-82c9-661a5cc366ec\" ]"
            }
          },
          {
            "name": "excludeMessageId",
            "in": "query",
            "description": "Force-exclude specific message UniqueIds even if they match participant filters (repeatable).",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"3b39ae56-f6f4-4e6c-82c9-661a5cc366ec\" ]"
            }
          },
          {
            "name": "folderUniqueId",
            "in": "query",
            "description": "Filter to messages whose junction maps to any of these folder uniqueIds (repeatable, OR logic). Single-mailbox mode. Mutually exclusive with systemFolderType.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"3b39ae56-f6f4-4e6c-82c9-661a5cc366ec\" ]"
            }
          },
          {
            "name": "systemFolderType",
            "in": "query",
            "description": "Filter to messages in folders of the given system type (Inbox/Sent/Drafts/...). Combined-mailbox mode. Mutually exclusive with folderUniqueId.",
            "schema": {
              "enum": [
                "None",
                "Inbox",
                "Sent",
                "Drafts",
                "Junk",
                "Trash",
                "Archive",
                "Outbox",
                "GmailCategory",
                "GmailPromotionalCategory",
                "OutsideFolderTree"
              ],
              "type": "string",
              "example": "Inbox"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalMailboxEmailSummaryDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/mailbox/send": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Send Email",
        "description": "Sends a composed email with automatic routing. If configCode is provided, sends via that mailbox — the user must own it or it must be send-shared, and it must be send-enabled. If omitted, uses the tenant's default mailbox. If no mailboxes are configured, sends via the platform default using the tenant's ReplyTo settings. When scheduledAt is set, the email is not sent now: a scheduled send is created and 202 is returned.\n\nRequires: Create on Mailbox.",
        "operationId": "SendEmail",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "configCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMailboxEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}": {
      "get": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Get Conversation",
        "description": "Returns all messages in a specific conversation thread, ordered by date, enriched with client associations based on participant email addresses matching client email rules. Each message includes summary fields (subject, sender, snippet, date) but not the full body - use the Get Message endpoint to retrieve the complete content. The configuration must have ReadEnabled set to true. On a mailbox sharing selected emails, non-owners see only the shared messages and get 404 when none is shared.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "GetMailboxConversation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationWithAssociationsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/messages/{messageId}": {
      "get": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Get Message",
        "description": "Returns the full details of a specific message including HTML/plain-text body, recipients (to, cc), and attachment metadata. The body is fetched on-demand from the email provider, so this call may be slower than list endpoints. The configuration must have ReadEnabled set to true. If the response includes ReconnectRequired=true, the OAuth connection needs to be re-authorised before further requests will succeed.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "GetMailboxMessage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalMailboxEmailDetailResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/messages": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Send new email",
        "description": "Sends a new email from the tenant's connected mailbox. The configuration must have SendEnabled set to true. The sender (From) is determined by the email configuration. At least one To recipient and either HtmlBody or PlainTextBody is required. Attachments are supported via base64-encoded content.\n\nRequires: Create on Mailbox.",
        "operationId": "SendMailboxMessage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMailboxEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendEmailResponse"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Create"
          }
        ]
      },
      "patch": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Mark messages as read or unread",
        "description": "Updates the read/unread status of one or more mailbox messages. The configuration must have ReadEnabled set to true. Provider sync (Microsoft Graph / Gmail) happens asynchronously — the response does not wait for the provider update.\n\nRequires: Update on Mailbox.",
        "operationId": "PatchMailboxMessages",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchMailboxMessageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/messages/{messageId}/reply": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Reply to Message",
        "description": "Sends a reply to a specific mailbox message via the email provider. The configuration must have SendEnabled set to true. Set ReplyAll to true to reply to all original recipients, or provide explicit ToRecipients/CcRecipients to override. Supports attachments via the Attachments array. Whether the original is quoted below the reply is the mailbox's QuoteOriginalInReplies setting; QuoteOriginal in the request is ignored. If the response includes ReconnectRequired=true, the OAuth connection needs to be re-authorised.\n\nRequires: Create on Mailbox.",
        "operationId": "ReplyToMailboxMessage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReplyMailboxEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReplyEmailResponse"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/messages/{messageId}/forward": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Forward Message",
        "description": "Forwards a specific mailbox message to new recipients via the email provider. The configuration must have SendEnabled set to true, and the caller must be able to read the message (403 otherwise). At least one To recipient is required. The email service appends the forwarded message (its header and body) after HtmlBody. Subject defaults to \"Fwd: \" and the original's subject. KeepAttachmentIds picks which original attachments to carry: null carries every non-inline one, an empty list none. New attachments go in the Attachments array, practice documents in PracticeDocumentCodes. Set ScheduledAt to schedule the forward instead (202). If the response includes ReconnectRequired=true, the OAuth connection needs to be re-authorised.\n\nRequires: Create on Mailbox.",
        "operationId": "ForwardMailboxMessage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ForwardMailboxEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReplyEmailResponse"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/drafts": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Create Draft",
        "description": "Creates a new draft via the email provider. The configuration must have ReadEnabled set to true. The returned UniqueId is used for subsequent Update/Send/Discard calls.\n\nRequires: Create on Mailbox.",
        "operationId": "CreateMailboxDraft",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMailboxDraftRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateDraftResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/messages/{messageId}/reply-draft": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Create Reply Draft",
        "description": "Creates a reply to a specific mailbox message as a draft in the message's conversation, addressed as the reply would be (set ReplyAll, or provide explicit ToRecipients/CcRecipients to override). Nothing is sent. The configuration must have ReadEnabled set to true; it does not need SendEnabled. The returned UniqueId is used for subsequent Update/Send/Discard calls. If the response includes ReconnectRequired=true, the OAuth connection needs to be re-authorised.\n\nRequires: Create on Mailbox.",
        "operationId": "CreateMailboxReplyDraft",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMailboxReplyDraftRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateDraftResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/drafts/{messageId}": {
      "patch": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Update Draft",
        "description": "Saves changes to an existing synced draft via the email provider. The configuration must have ReadEnabled set to true. Every field is the draft's new full content, not an override — omit Attachments to leave the draft's existing attachments untouched. If the response includes ReconnectRequired=true, the OAuth connection needs to be re-authorised.\n\nRequires: Update on Mailbox.",
        "operationId": "UpdateMailboxDraft",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMailboxDraftRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DraftOperationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Discard Draft",
        "description": "Discards an existing draft via the email provider. The configuration must have ReadEnabled set to true. The draft is removed from the connected mailbox and no longer shown in Sodium.\n\nRequires: Update on Mailbox.",
        "operationId": "DeleteMailboxDraft",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DraftOperationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/drafts/{messageId}/send": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Send Draft",
        "description": "Sends an existing draft exactly as saved. The configuration must have SendEnabled set to true. The draft leaves Drafts and appears as sent, both in the connected mailbox and in Sodium. If the response includes ReconnectRequired=true, the OAuth connection needs to be re-authorised.\n\nRequires: Create on Mailbox.",
        "operationId": "SendMailboxDraft",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DraftOperationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/messages/{messageId}/attachments/{attachmentId}": {
      "get": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Get Attachment",
        "description": "Streams the raw content of a message attachment. Use for downloading files and resolving inline CID images in HTML email bodies. Returns the file with its original content type and caches for 1 hour.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "GetMailboxMessageAttachment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "attachmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/move": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Move Conversation",
        "description": "Moves a conversation from one folder of the mailbox to another, in the connected mailbox and in Sodium. Only the conversation's messages in the source folder move, so replies filed in Sent stay where they are. Open to the mailbox's owner and, on a mailbox shared with everyone, to colleagues; a mailbox sharing selected emails refuses them. Success is false when the provider refused some or all of the move; MovedCount says how many messages went through. If the response includes ReconnectRequired=true, the OAuth connection needs to be re-authorised.\n\nRequires: Update on Mailbox.",
        "operationId": "MoveMailboxConversation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MoveMailboxConversationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MoveMailboxMessagesResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/messages/{messageId}/split": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Split Message into its own Conversation",
        "description": "Moves one email out of the conversation Outlook or Gmail filed it in, into a conversation of its own, so it can be linked and triaged by itself. The conversation it leaves keeps its status, links, comments and tasks. An email alone in its conversation stays as it is (splitEmailCount 0). Later replies to it still join the original conversation. Open to the mailbox's owner and, on a mailbox shared with everyone, to colleagues; a mailbox sharing selected emails refuses them.\n\nRequires: Update on Mailbox.",
        "operationId": "SplitMailboxMessage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SplitMailboxMessageResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/tasks": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Link Task to Conversation",
        "description": "Creates an association between an email conversation and a task item.\n\nRequires: Update on Mailbox.",
        "operationId": "LinkConversationTask",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkConversationTaskRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodeAndNameDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/tasks/{taskCode}": {
      "delete": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Unlink Task from Conversation",
        "description": "Removes the association between an email conversation and a task item.\n\nRequires: Update on Mailbox.",
        "operationId": "UnlinkConversationTask",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/clients": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Link Client to Conversation",
        "description": "Links this one conversation to a client, whatever its addresses. Use it when an address is shared by several clients and an email rule would be too broad. Replaces an earlier removal of the conversation from the same client.\n\nRequires: Update on Mailbox.",
        "operationId": "LinkConversationClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkConversationClientRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationClientAssociationDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/clients/{clientCode}": {
      "delete": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Remove Conversation from Client",
        "description": "Takes this one conversation off a client. It stays off even when one of the client's email rules matches it, and the client's other emails are unaffected. Linking the conversation to the client again reverses it.\n\nRequires: Update on Mailbox.",
        "operationId": "RemoveConversationClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/sync": {
      "post": {
        "tags": [
          "Email - Mailbox"
        ],
        "summary": "Trigger Mailbox Sync",
        "description": "Queues an immediate sync for this mailbox configuration. Returns 202 Accepted — the sync happens asynchronously. New emails will appear after the sync completes (typically a few seconds). User must be the connection's owner or an admin.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "TriggerMailboxSync",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-settings": {
      "get": {
        "tags": [
          "Email - Settings"
        ],
        "summary": "Get email settings",
        "description": "Returns the email settings for the specified tenant\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetEmailSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Email - Settings"
        ],
        "summary": "Update email settings",
        "description": "Updates the email settings for the specified tenant\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateEmailSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEmailSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-triage-statuses": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "List EmailTriageStatuss",
        "description": "Lists all EmailTriageStatuss for the given tenant.\n\nOpen to any signed-in user of the tenant: Practice-wide reference list of email conversation statuses, readable by every user in the practice",
        "operationId": "ListEmailTriageStatuss",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/EmailTriageStatusSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "isActive",
            "in": "query",
            "description": "Filter by whether the status is active (offered when setting a conversation's status)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTriageStatusDtoPagedResult"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Practice-wide reference list of email conversation statuses, readable by every user in the practice"
      },
      "post": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Create EmailTriageStatus",
        "description": "Creates a new EmailTriageStatus for the specified tenant.\n\nRequires: Create on EmailTriage.",
        "operationId": "CreateEmailTriageStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEmailTriageStatusRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTriageStatusDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailTriage",
            "permission": "Create"
          }
        ]
      },
      "patch": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Reorder Email Triage Statuses",
        "description": "Saves the complete new order of the tenant's email triage statuses in a single change. Each\ncode's sort order becomes its 0-based position in the list. Rejected as a whole when the list is\nempty, contains duplicates, or names a status that does not exist.\n\nRequires: Update on EmailTriage.",
        "operationId": "ReorderEmailTriageStatuses",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReorderEmailTriageStatusesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailTriage",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-triage-statuses/{code}": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Get EmailTriageStatus",
        "description": "Gets a EmailTriageStatus for the specified tenant.\n\nOpen to any signed-in user of the tenant: Practice-wide reference list of email conversation statuses, readable by every user in the practice",
        "operationId": "GetEmailTriageStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTriageStatusDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Practice-wide reference list of email conversation statuses, readable by every user in the practice"
      },
      "put": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Update EmailTriageStatus",
        "description": "Updates a EmailTriageStatus for the specified tenant.\n\nRequires: Update on EmailTriage.",
        "operationId": "UpdateEmailTriageStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEmailTriageStatusRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTriageStatusDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailTriage",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Delete EmailTriageStatus",
        "description": "Deletes a EmailTriageStatus for the specified tenant.\n\nRequires: Delete on EmailTriage.",
        "operationId": "DeleteEmailTriageStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailTriage",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-triage-header-widgets": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "List EmailTriageHeaderWidgets",
        "description": "Lists all EmailTriageHeaderWidgets for the given tenant.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "ListEmailTriageHeaderWidgets",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/EmailTriageHeaderWidgetSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTriageHeaderWidgetDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Create EmailTriageHeaderWidget",
        "description": "Creates a new EmailTriageHeaderWidget for the specified tenant.\n\nRequires: Create on EmailTriage.",
        "operationId": "CreateEmailTriageHeaderWidget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveEmailTriageHeaderWidgetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTriageHeaderWidgetDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailTriage",
            "permission": "Create"
          }
        ]
      },
      "patch": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Reorder Email Triage Header Widgets",
        "description": "Saves the complete new order of the practice's email page header widgets in a single change. Each\ncode's sort order becomes its 0-based position in the list. Rejected as a whole when the list is\nempty, contains duplicates, or names a widget that does not exist.\n\nRequires: Update on EmailTriage.",
        "operationId": "ReorderEmailTriageHeaderWidgets",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReorderEmailTriageHeaderWidgetsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailTriage",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-triage-header-widgets/{code}": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Get EmailTriageHeaderWidget",
        "description": "Gets a EmailTriageHeaderWidget for the specified tenant.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "GetEmailTriageHeaderWidget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTriageHeaderWidgetDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Update EmailTriageHeaderWidget",
        "description": "Updates a EmailTriageHeaderWidget for the specified tenant.\n\nRequires: Update on EmailTriage.",
        "operationId": "UpdateEmailTriageHeaderWidget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveEmailTriageHeaderWidgetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTriageHeaderWidgetDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailTriage",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Delete EmailTriageHeaderWidget",
        "description": "Deletes a EmailTriageHeaderWidget for the specified tenant.\n\nRequires: Delete on EmailTriage.",
        "operationId": "DeleteEmailTriageHeaderWidget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailTriage",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/not-client-email-rules": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "List NotClientEmailRules",
        "description": "Lists all NotClientEmailRules for the given tenant.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "ListNotClientEmailRules",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/NotClientEmailRuleSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotClientEmailRuleDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Create NotClientEmailRule",
        "description": "Creates a new NotClientEmailRule for the specified tenant.\n\nRequires: Update on Mailbox.",
        "operationId": "CreateNotClientEmailRule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNotClientEmailRuleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotClientEmailRuleDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/not-client-email-rules/{code}": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Get NotClientEmailRule",
        "description": "Gets a NotClientEmailRule for the specified tenant.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "GetNotClientEmailRule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotClientEmailRuleDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      },
      "delete": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Delete NotClientEmailRule",
        "description": "Deletes a NotClientEmailRule for the specified tenant.\n\nRequires: Update on Mailbox.",
        "operationId": "DeleteNotClientEmailRule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-address-classification": {
      "post": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Classify Email Addresses",
        "description": "Says what each address is to the practice: Internal (a team member's sign-in or other address,\nor a connected mailbox), Client (one of a client's email rules matches the address or its domain),\nNotClient (the address or its domain is marked as not a client) or Unknown, in that order of\nprecedence. A client match names the client only when exactly one client matches and the caller\nmay see it. At most 100 addresses per call.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "ClassifyEmailAddresses",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClassifyEmailAddressesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmailAddressClassificationDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/triage-settings": {
      "put": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Update Triage Settings",
        "description": "Switches email triage on or off for the mailbox and sets the status new conversations start at\nand who they are assigned to by default: nobody, a named user (who must be able to read the\nmailbox), the client's manager, partner or associate (the role must be switched on in client\nsettings), or the practice user the email was sent to. assigneeUserCodes narrows who can be assigned\nits conversations to those people (each must read the mailbox; null for everyone who does). Triage needs a connection that receives\nemails, and a default status that is active and does not mean Done. Only the connection's owner\nor an admin can change it.\n\nRequires: Update on EmailConnections.",
        "operationId": "UpdateEmailConfigTriageSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEmailTriageSettingsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailConfigDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/triage/users": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "List Triage Users",
        "description": "The people who can read the whole mailbox: its owner, and everyone when it is shared with\neveryone. Only they can be assigned its conversations or mentioned in its comments. Empty when the\nmailbox is not active or does not receive emails.\n\nRequires at least one of: ViewAll on Mailbox or Update on EmailConnections.",
        "operationId": "ListEmailConfigTriageUsers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmailTriageUserDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "Mailbox",
              "permission": "ViewAll"
            },
            {
              "entity": "EmailConnections",
              "permission": "Update"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/triage/assignees": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "List Triage Assignees",
        "description": "The people the mailbox's conversations can be assigned to: everyone who can read the whole\nmailbox (as triage/users), narrowed to the mailbox's assignee list when it has one. Empty when the\nmailbox is not active or does not receive emails.\n\nRequires at least one of: ViewAll on Mailbox or Update on EmailConnections.",
        "operationId": "ListEmailConfigTriageAssignees",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmailTriageUserDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "Mailbox",
              "permission": "ViewAll"
            },
            {
              "entity": "EmailConnections",
              "permission": "Update"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/triage": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Get Conversation Triage",
        "description": "Returns the conversation's triage state: its effective status code (its own, else the first active\nDone status when it predates triage being switched on, else the mailbox's default, as the list shows\nit), assignee code, who assigned it, whether the assigner asked to hear when it is done, when the\nstatus was last set, its classification, and how many comments it has. Only on a mailbox with\ntriage on, for people who can read the whole mailbox.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "GetConversationTriage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationTriageDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Update Conversation Triage",
        "description": "Sets the conversation's status (setStatus + statusCode, an active status), its assignee (setAssignee +\nassigneeCode, someone who can read the whole mailbox; null unassigns), or both. The caller becomes the\nassigner, and notifyMeWhenDone says whether they hear when someone else sets a Done status. A new\nassignee other than the caller is notified. With silent, nobody is notified and the assigner and\nnotifyMeWhenDone stay as they were, so a conversation can be taken and handed back unnoticed. A Done status that archives also archives the conversation\nin Outlook or Gmail; a failed archive does not fail the change. Returns the saved triage state.\n\nRequires: Update on Mailbox.",
        "operationId": "UpdateConversationTriage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetConversationTriageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationTriageDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/comments": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "List Conversation Comments",
        "description": "Returns the internal comments on the conversation, oldest first. Only for people who can read the whole mailbox.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "ListConversationComments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ConversationCommentDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Add Conversation Comment",
        "description": "Adds an internal comment to the conversation. Mention someone as @[Name](user-code): the people it\nmentions who can read the mailbox are notified.\n\nRequires: Update on Mailbox.",
        "operationId": "CreateConversationComment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveConversationCommentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationCommentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/comments/{commentCode}": {
      "put": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Update Conversation Comment",
        "description": "Replaces the text of one of your own comments. Only people it newly mentions are notified.\n\nRequires: Update on Mailbox.",
        "operationId": "UpdateConversationComment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "commentCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveConversationCommentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationCommentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Delete Conversation Comment",
        "description": "Deletes one of your own comments.\n\nRequires: Update on Mailbox.",
        "operationId": "DeleteConversationComment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "commentCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/summary": {
      "put": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Update Conversation Summary",
        "description": "Saves the conversation's summary as written by hand, replacing any summary there was, AI-written or\nnot, and returns it. Empty text deletes the summary (204). Refused while the mailbox's summaries are\nswitched off. Only for people who can read the whole mailbox.\n\nRequires: Update on Mailbox.",
        "operationId": "UpdateConversationSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveConversationSummaryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationSummaryDto"
                }
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/email-configs/{code}/conversations/{conversationId}/summary/generate": {
      "post": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Generate Conversation Summary",
        "description": "Sends the conversation's newest messages, as the caller may read them, to the AI and saves its answer as\nthe conversation's summary, replacing any summary there was, and returns it. Refused while the mailbox's\nsummaries or AI summaries are switched off, when the mailbox needs reconnecting, and when the conversation\nhas no text. Only for people who can read the whole mailbox. 502 when the AI service fails.\n\nRequires: Update on Mailbox.",
        "operationId": "GenerateConversationSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationSummaryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "502": {
            "description": "Bad Gateway"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/mailbox/triage-counts": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Get Triage Counts",
        "description": "Counts the open conversations (not at a Done status) in the Matched, Unmatched and Other triage\nviews, and those assigned to the caller (assignedToMe). Scoped as the conversation list is: the\ncaller's own and everyone-shared mailboxes, narrowed by configCode (repeatable), counting only\nmailboxes with triage on. Like the triage views, they cover Inbox conversations only.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "GetMailboxTriageCounts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "configCode",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationTriageCountsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/mailbox/triage-breakdown": {
      "get": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Get Triage Breakdown",
        "description": "Counts conversations per effective triage status and assignee, one row per pair, for the\ndashboard. Every conversation counts, open or done; a conversation from before triage was\nswitched on shows at the first active Done status. Scoped as triage-counts is: the caller's own\nand everyone-shared mailboxes with triage on, narrowed by configCode (repeatable), over Inbox\nconversations only.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "GetMailboxTriageBreakdown",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "configCode",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TriageBreakdownRowDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/mailbox/conversations/triage": {
      "post": {
        "tags": [
          "Email - Triage"
        ],
        "summary": "Bulk Update Conversation Triage",
        "description": "Makes one triage change (setStatus + statusCode, setAssignee + assigneeCode, setBringBack, as on a single\nconversation) to up to 100 conversations, which may be in different mailboxes. Each mailbox must have triage on and\nbe read in full by the caller; a colleague changes only conversations the owner's exclusion rules leave visible,\nand a colleague is assigned only those. A conversation that fails a check, or whose write fails, is listed in\nskipped with its reason (triageOff, noAccess, hidden, assigneeNotAllowed, changed, failed) and the rest are still\nchanged. The new assignee hears once per mailbox, and so does each assigner who asked to hear of Done.\n\nRequires: Update on Mailbox.",
        "operationId": "BulkUpdateConversationTriage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkConversationTriageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkConversationTriageResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "Update"
          }
        ]
      }
    },
    "/engagements/accept/{guid}/portal-url": {
      "get": {
        "tags": [
          "Engagement - Acceptance"
        ],
        "summary": "Get Acceptance Page URL",
        "description": "Resolves an engagement GUID to the client portal URL where the acceptance flow is hosted.\n\nExists so the retired `/engagements/accept/{guid}` page in the practice web app can redirect\nlinks from proposal emails that were sent before the flow moved to the portal.",
        "operationId": "GetEngagementAcceptancePortalUrl",
        "parameters": [
          {
            "name": "guid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementAcceptanceUrlDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/tenants/{tenant}/practice/engagement-settings": {
      "get": {
        "tags": [
          "Engagement - Settings"
        ],
        "summary": "Get engagement settings",
        "description": "Returns the engagement settings for the specified tenant\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetEngagementSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Engagement - Settings"
        ],
        "summary": "Update engagement settings",
        "description": "Updates the engagement settings for the specified tenant\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateEngagementSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEngagementSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/engagements/{code}/pdf/{pdfType}/stream": {
      "get": {
        "tags": [
          "Engagements"
        ],
        "summary": "Stream Engagement PDF",
        "description": "Streams an engagement PDF. Requires a valid signed token. Used for mobile PDF viewing via Google Docs Viewer.",
        "operationId": "StreamEngagementPdf",
        "parameters": [
          {
            "name": "tenant",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "disposition",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "expires",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            },
            "x-order": 400
          },
          {
            "name": "pdfType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/tenants/{tenant}/engagements": {
      "get": {
        "tags": [
          "Engagements"
        ],
        "summary": "List Engagements",
        "description": "Lists all Engagements for the given tenant.\n\nRequires: ViewAll on Engagements.",
        "operationId": "ListEngagements",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/EngagementSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter to engagements belonging to a single client",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by engagement status (Unsent, Sent, Accepted, Rejected)",
            "schema": {
              "enum": [
                "Unsent",
                "Sent",
                "Viewed",
                "Accepted",
                "Rejected"
              ],
              "type": "string",
              "example": "Sent"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across engagement code, client name, and client code (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "acme"
            }
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range. If CustomDateRange, dateFrom and dateTo are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "description": "Filter engagements from this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "description": "Filter engagements up to this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Engagements"
        ],
        "summary": "Create Engagement",
        "description": "Creates a new Engagement for the specified tenant.\n\nRequires: Create on Engagements.",
        "operationId": "CreateEngagement",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEngagementRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "Create"
          }
        ]
      },
      "delete": {
        "tags": [
          "Engagements"
        ],
        "summary": "Bulk Delete Draft Engagements",
        "description": "Deletes multiple unsent (draft) proposals at once. Proposals that have been sent, viewed, accepted or rejected are not deleted and are returned in skippedCodes. Unknown codes are ignored.\n\nRequires: Delete on Engagements.",
        "operationId": "BulkDeleteDraftEngagements",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkDeleteDraftEngagementsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeleteDraftEngagementsResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/engagements/{code}": {
      "get": {
        "tags": [
          "Engagements"
        ],
        "summary": "Get Engagement",
        "description": "Gets a Engagement for the specified tenant.\n\nRequires: ViewAll on Engagements.",
        "operationId": "GetEngagement",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Engagements"
        ],
        "summary": "Update Engagement",
        "description": "Updates a Engagement for the specified tenant.\n\nRequires: Update on Engagements.",
        "operationId": "UpdateEngagement",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEngagementRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Engagements"
        ],
        "summary": "Delete Engagement",
        "description": "Deletes a Engagement for the specified tenant.\n\nRequires: Delete on Engagements.",
        "operationId": "DeleteEngagement",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/engagements/summary": {
      "get": {
        "tags": [
          "Engagements"
        ],
        "summary": "Get Engagement Summary",
        "description": "Returns a count and total annual value of engagements grouped by status for the tenant.\n\nOptionally filter by date range:\n- Use dateRange for preset ranges (ThisWeek, ThisMonth, ThisYear, etc.)\n- Use dateFrom/dateTo for custom ranges (when dateRange is CustomDateRange)\n- When using a preset range, dateFrom and dateTo must not be provided\n\nRequires: ViewAll on Engagements.",
        "operationId": "GetEngagementSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "dateRange",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PresetDateRange"
            },
            "x-order": 400
          },
          {
            "name": "dateTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementSummaryDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/engagements/{code}/email": {
      "post": {
        "tags": [
          "Engagements"
        ],
        "summary": "Email Engagement",
        "description": "Sends an email for the engagement using the tenant's email settings.\n\nThe email will be sent to the recipient specified in the engagement.\nThe email will be queued for sending and a message ID will be returned.\nA record will be created linking the engagement to the sent email.\n\nThe body is optional. It carries per-send choices made on the send screen: which sales pipeline\n(if any) to add the client to, overriding Proposal Settings for this send only, the mailbox to\nsend from, and the email as the sender edited it.\n\nWhen scheduledAt is set, nothing is sent now: a scheduled send emails the proposal at that time\nand 202 is returned with the scheduled send. The proposal keeps its status until then, and only\none scheduled email can be waiting per proposal.\n\ncomposedSubject and composedBodyHtml carry an email the sender edited, starting from the preview\n(GET /{code}/email/preview). They are sent in place of the practice's proposal email template.\n\nRequires: Update on Engagements.",
        "operationId": "SendEngagementEmail",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendEngagementEmailRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "Update"
          }
        ]
      },
      "get": {
        "tags": [
          "Engagements"
        ],
        "summary": "Get Engagement Emails",
        "description": "Gets all emails that have been sent for a specific engagement.\n\nReturns a list of emails with their message IDs and sent dates.\nThe list is ordered by most recent first.\n\nRequires: ViewAll on Engagements.",
        "operationId": "GetEngagementEmails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EngagementEmailDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/engagements/{code}/email/preview": {
      "get": {
        "tags": [
          "Engagements"
        ],
        "summary": "Preview Engagement Email",
        "description": "Returns the email that sending the engagement would send now, for the sender to read and edit first:\nthe practice's proposal email template filled in for this proposal and its recipient, with the sending\nmailbox's signature. Sends nothing and changes nothing.\n\nsenderMailboxCode is the mailbox the sender chose on the send screen, as on the send. Its signature is\nthe one the preview carries. Omit it to follow the practice's client email sender rule.\n\nSend the edited subject and body back as composedSubject and composedBodyHtml on POST /{code}/email.\n\nRequires: Update on Engagements.",
        "operationId": "PreviewEngagementEmail",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "senderMailboxCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepEmailPreviewDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/engagements/{code}/acceptance-steps": {
      "get": {
        "tags": [
          "Engagements"
        ],
        "summary": "Get Engagement Acceptance Steps",
        "description": "Lists the steps an accepted proposal asked the client to complete (Direct Debit, identity\nverification, each form) and whether each is done. Empty until the proposal is accepted.\n\nIdentity verification is checked live with the practice's AML platform, which may make this\nslower than other reads; when the platform can't be asked the step's status is Unknown.\nNothing is created or sent: unlike the client's acceptance page, this never requests a\nmandate link or an onboarding request.\n\nRequires: ViewAll on Engagements.",
        "operationId": "GetEngagementAcceptanceSteps",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EngagementAcceptanceStepStatusDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/engagements/{code}/pdf/proposal": {
      "post": {
        "tags": [
          "Engagements"
        ],
        "summary": "Upload proposal PDF",
        "description": "Uploads a PDF document for the proposal.\n\nThe PDF should be sent as a base64-encoded string in the request body.\n\nRequest body example:\n{\n  \"pdfContent\": \"JVBERi0xLjQKJeLj...\"  // Base64-encoded PDF content\n}\n\nThe uploaded PDF will be stored in Azure Blob Storage and associated with this engagement.\nThe engagement's HasProposalPdf flag will be set to true upon successful upload.\n\nYou can retrieve this PDF later using the GET /{code}/pdf/proposal endpoint.\n\nNote: Uploading a new PDF will replace any existing proposal PDF for this engagement.\n\nRequires: Update on Engagements.",
        "operationId": "UploadEngagementProposalPdf",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UploadEngagementPdfRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "Update"
          }
        ]
      },
      "get": {
        "tags": [
          "Engagements"
        ],
        "summary": "Download proposal PDF",
        "description": "Downloads the proposal PDF document.\n\nReturns the PDF file as binary content with appropriate headers for download.\nThe response will include a Content-Disposition header with a filename in the format:\nproposal-{code}-{date}.pdf\n\nPrerequisites:\n- The engagement must exist\n- A PDF must have been previously uploaded (HasProposalPdf must be true)\n\nReturns:\n- 200: PDF file as application/pdf binary content\n- 404: If the engagement or PDF file is not found\n\nRequires: ViewAll on Engagements.",
        "operationId": "GetEngagementProposalPdf",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "disposition",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/engagements/{code}/pdf/letter-of-engagement": {
      "post": {
        "tags": [
          "Engagements"
        ],
        "summary": "Upload letter of engagement PDF",
        "description": "Uploads a letter of engagement PDF document for the engagement.\n\nThe PDF should be sent as a base64-encoded string in the request body.\n\nRequest body example:\n{\n  \"pdfContent\": \"JVBERi0xLjQKJeLj...\"  // Base64-encoded PDF content\n}\n\nThe uploaded PDF will be stored in Azure Blob Storage and associated with this engagement.\nThe engagement's HasLofEPdf flag will be set to true upon successful upload.\n\nYou can retrieve this PDF later using the GET /{code}/pdf/letter-of-engagement endpoint.\n\nNote: Uploading a new PDF will replace any existing letter of engagement for this engagement.\n\nRequires: Update on Engagements.",
        "operationId": "UploadEngagementLetterOfEngagementPdf",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UploadEngagementPdfRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "Update"
          }
        ]
      },
      "get": {
        "tags": [
          "Engagements"
        ],
        "summary": "Download letter of engagement PDF",
        "description": "Downloads the letter of engagement PDF document.\n\nReturns the PDF file as binary content with appropriate headers for download.\nThe response will include a Content-Disposition header with a filename in the format:\nletter-of-engagement-{code}-{date}.pdf\n\nPrerequisites:\n- The engagement must exist\n- A letter of engagement PDF must have been previously uploaded (HasLofEPdf must be true)\n\nReturns:\n- 200: PDF file as application/pdf binary content\n- 404: If the engagement or letter of engagement PDF is not found\n\nRequires: ViewAll on Engagements.",
        "operationId": "GetEngagementLetterOfEngagementPdf",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "disposition",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/engagements/{code}/custom-token-values": {
      "put": {
        "tags": [
          "Engagements"
        ],
        "summary": "Update Engagement Custom Token Values",
        "description": "Replaces the custom token values the engagement's proposal and letter of engagement are rendered with,\nkeyed as the template's token list names them (e.g. \"Custom.FeeNotes\"). Stored so that regenerating the\ndocuments after an edit reuses them. Only allowed while the engagement is unsent.\n\nRequires: Update on Engagements.",
        "operationId": "UpdateEngagementCustomTokenValues",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEngagementCustomTokenValuesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Engagements",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/external-proposals": {
      "get": {
        "tags": [
          "External Proposals"
        ],
        "summary": "List External Proposals",
        "description": "Lists proposals from the tenant's configured external proposal platform (e.g., Socket)\n\nRequires: ViewAll on Clients and ViewAll on ClientBillableServices and ViewAll on Engagements.",
        "operationId": "ListExternalProposals",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 200
          },
          {
            "name": "processing",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0,
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20,
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ExternalProposalSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalProposalDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "ClientBillableServices",
            "permission": "ViewAll"
          },
          {
            "entity": "Engagements",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/external-proposals/{proposalId}": {
      "get": {
        "tags": [
          "External Proposals"
        ],
        "summary": "Get External Proposal",
        "description": "Gets a single proposal from the tenant's configured external proposal platform\n\nRequires: ViewAll on Clients and ViewAll on ClientBillableServices and ViewAll on BillableServices and ViewAll on Engagements.",
        "operationId": "GetExternalProposal",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "proposalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalProposalDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "ClientBillableServices",
            "permission": "ViewAll"
          },
          {
            "entity": "BillableServices",
            "permission": "ViewAll"
          },
          {
            "entity": "Engagements",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/external-proposals/service-mapping": {
      "put": {
        "tags": [
          "External Proposals"
        ],
        "summary": "Map External Service",
        "description": "Maps an external service template to a Sodium BillableService, or marks it ignored so no Sodium service is created for it. Creates or updates the mapping.\n\nRequires: Update on BillableServices.",
        "operationId": "UpsertExternalServiceMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertServiceMappingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalServiceMappingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/external-proposals/{proposalId}/apply/{clientCode}": {
      "post": {
        "tags": [
          "External Proposals"
        ],
        "summary": "Apply External Proposal",
        "description": "Applies a proposal from the external proposal platform to its client: creates the services the client lacks, activates the proposal's Proposed services when it is won, and updates services whose price or billing period the proposal has changed. Each change's history names the proposal. The request can switch off onboarding tasks for the services it adds and set their start date.\n\nRequires: Create on ClientBillableServices and Update on ClientBillableServices.",
        "operationId": "ApplyExternalProposal",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "proposalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyExternalProposalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplyExternalProposalResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Create"
          },
          {
            "entity": "ClientBillableServices",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/filing-credits/balance": {
      "get": {
        "tags": [
          "Filing Credits"
        ],
        "summary": "Get Filing Credit Balance",
        "description": "Returns the practice's remaining filing credits. Submitting to HMRC spends credits per the configured cost of the filing type; a submission is refused when the balance cannot cover it. Readable with View on MTD Income Tax or on Sodium Product Accounts, because MTD filings and the practice's CIS Manager returns both spend them.\n\nRequires at least one of: ViewAll on MakingTaxDigitalIncomeTax or ViewAll on ProductAccounts.",
        "operationId": "GetFilingCreditBalance",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingCreditBalanceDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "MakingTaxDigitalIncomeTax",
              "permission": "ViewAll"
            },
            {
              "entity": "ProductAccounts",
              "permission": "ViewAll"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/filing-credits": {
      "get": {
        "tags": [
          "Filing Credits"
        ],
        "summary": "Get Filing Credits",
        "description": "Returns the practice's filing credits for the Filing Credits tab: the balance, the price of a block, the automatic top-up and this month's use of it, and whether the practice has a Direct Debit that can collect (buying and switching top-up on need one). Billing View.\n\nRequires: ViewAll on Billing.",
        "operationId": "GetFilingCredits",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingCreditsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/filing-credits/purchases": {
      "get": {
        "tags": [
          "Filing Credits"
        ],
        "summary": "List Filing Credit Purchases",
        "description": "Returns the practice's purchases and automatic top-ups, newest first. Billing View.\n\nRequires: ViewAll on Billing.",
        "operationId": "ListFilingCreditPurchases",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingCreditPurchaseDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Filing Credits"
        ],
        "summary": "Purchase Filing Credits",
        "description": "Buys blocks of filing credits, added to the practice's next invoice and collected by Direct Debit. Billing Admin, and a Direct Debit that can collect (409 errorCode billing_mandate_required otherwise). The same request id again answers the first purchase and buys nothing.\n\nRequires: Admin on Billing.",
        "operationId": "PurchaseFilingCredits",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PurchaseFilingCreditsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingCreditPurchaseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/filing-credits/settings": {
      "put": {
        "tags": [
          "Filing Credits"
        ],
        "summary": "Update Filing Credit Settings",
        "description": "Replaces the practice's automatic top-up; null switches it off. Billing Admin. Switching it on needs a Direct Debit that can collect (409 errorCode billing_mandate_required); a 409 without a code means someone else changed it meanwhile.\n\nRequires: Admin on Billing.",
        "operationId": "UpdateFilingCreditSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateFilingCreditSettingsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingCreditsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/hmrc-credentials": {
      "get": {
        "tags": [
          "HMRC Agent Credentials"
        ],
        "summary": "List HmrcAgentCredentials",
        "description": "Lists all HmrcAgentCredentials for the given tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "ListHmrcAgentCredentials",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/HmrcAgentCredentialSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcAgentCredentialDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "HMRC Agent Credentials"
        ],
        "summary": "Create HmrcAgentCredential",
        "description": "Creates a new HmrcAgentCredential for the specified tenant.\n\nRequires: Create on PracticeDetails.",
        "operationId": "CreateHmrcAgentCredential",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateHmrcAgentCredentialRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcAgentCredentialDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/hmrc-credentials/{code}": {
      "get": {
        "tags": [
          "HMRC Agent Credentials"
        ],
        "summary": "Get HmrcAgentCredential",
        "description": "Gets a HmrcAgentCredential for the specified tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetHmrcAgentCredential",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcAgentCredentialDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "HMRC Agent Credentials"
        ],
        "summary": "Update HmrcAgentCredential",
        "description": "Updates a HmrcAgentCredential for the specified tenant.\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateHmrcAgentCredential",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateHmrcAgentCredentialRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcAgentCredentialDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "HMRC Agent Credentials"
        ],
        "summary": "Delete HmrcAgentCredential",
        "description": "Deletes a HmrcAgentCredential for the specified tenant.\n\nRequires: Delete on PracticeDetails.",
        "operationId": "DeleteHmrcAgentCredential",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/hmrc-credentials/options": {
      "get": {
        "tags": [
          "HMRC Agent Credentials"
        ],
        "summary": "List HMRC Agent Credential Options",
        "description": "Returns the code and name of each credential set, default first, for choosing which Government Gateway login makes a letter-based 64-8 request and for labelling requests on the client page. Gated like the client page rather than like the settings page: names only, no credentials.\n\nRequires: ViewAll on Clients.",
        "operationId": "listHmrcAgentCredentialOptions",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/HmrcAgentCredentialOptionDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/hmrc-credentials/{code}/make-default": {
      "post": {
        "tags": [
          "HMRC Agent Credentials"
        ],
        "summary": "Make HMRC Agent Credential Default",
        "description": "Makes this set the default: MTD uses its ARN, and letter-based requests use it when no set is chosen.\n\nRequires: Update on PracticeDetails.",
        "operationId": "makeDefaultHmrcAgentCredential",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcAgentCredentialDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/hmrc/connection": {
      "get": {
        "tags": [
          "HMRC Connection"
        ],
        "summary": "Get HMRC Connection Status",
        "description": "Returns the practice's HMRC connection status.\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "getHmrcConnectionStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcConnectionStatusDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "HMRC Connection"
        ],
        "summary": "Connect to HMRC",
        "description": "Starts the HMRC consent journey and returns the authorization URL to send the user to.\n\nRequires: Create on ThirdPartyConnections.",
        "operationId": "connectHmrc",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectHmrcRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HmrcConnectResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Create"
          }
        ]
      },
      "delete": {
        "tags": [
          "HMRC Connection"
        ],
        "summary": "Disconnect from HMRC",
        "description": "Revokes the practice's active HMRC connection.\n\nRequires: Delete on ThirdPartyConnections.",
        "operationId": "disconnectHmrc",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/holidays": {
      "get": {
        "tags": [
          "Holidays"
        ],
        "summary": "List days",
        "description": "Lists all days for the given tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "Listdays",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TenantHolidaySortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantHolidayDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Holidays"
        ],
        "summary": "Create TenantHoliday",
        "description": "Creates a new TenantHoliday for the specified tenant.\n\nRequires: Create on PracticeDetails.",
        "operationId": "CreateTenantHoliday",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTenantHolidayRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantHolidayDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/holidays/{code}": {
      "get": {
        "tags": [
          "Holidays"
        ],
        "summary": "Get TenantHoliday",
        "description": "Gets a TenantHoliday for the specified tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetTenantHoliday",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantHolidayDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Holidays"
        ],
        "summary": "Update TenantHoliday",
        "description": "Updates a TenantHoliday for the specified tenant.\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateTenantHoliday",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTenantHolidayRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantHolidayDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Holidays"
        ],
        "summary": "Delete TenantHoliday",
        "description": "Deletes a TenantHoliday for the specified tenant.\n\nRequires: Delete on PracticeDetails.",
        "operationId": "DeleteTenantHoliday",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/import-jobs/{code}": {
      "get": {
        "tags": [
          "Import Jobs"
        ],
        "summary": "Get Import Job Status",
        "description": "Returns the current status of an import job, including a Companies House enrichment started from the client list. 404 for another user's job when client visibility narrows the caller.\n\nRequires at least one of: Import on Clients or Update on Clients.",
        "operationId": "GetImportJob",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJobDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "Clients",
              "permission": "Import"
            },
            {
              "entity": "Clients",
              "permission": "Update"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/import-jobs/{code}/clients": {
      "get": {
        "tags": [
          "Import Jobs"
        ],
        "summary": "Get Import Job Clients",
        "description": "Returns the outcome of each client in an import job, including the reason any client failed. Filter with the status query parameter (e.g. status=Failed) to retrieve only the failures. Also returns the clients a Companies House enrichment could not enrich.\n\nRequires at least one of: Import on Clients or Update on Clients.",
        "operationId": "GetImportJobClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/ImportJobClientStatus"
            },
            "x-order": 200
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJobClientDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "Clients",
              "permission": "Import"
            },
            {
              "entity": "Clients",
              "permission": "Update"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/import-jobs": {
      "get": {
        "tags": [
          "Import Jobs"
        ],
        "summary": "List Import Jobs",
        "description": "Returns a paginated list of import jobs for the tenant. A user client visibility narrows sees only the jobs they started.\n\nRequires: Import on Clients.",
        "operationId": "ListImportJobs",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/accounting/customers": {
      "get": {
        "tags": [
          "Integrations - Accounting"
        ],
        "summary": "List Customers",
        "description": "Lists all customers in the accounting platform. The platform is the ThirdPartyConnection.Code set in Tenant.AccountingConnectionCode \n\nRequires: ViewAll on Clients.",
        "operationId": "GetAccountingCustomers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerDto"
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad Gateway",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Integrations - Accounting"
        ],
        "summary": "Create Customer",
        "description": "Creates as new AccountingCustomer via the ThirdPartyConnection set as Tenant.AccountingConnectionCode\n\nRequires: Update on Clients.",
        "operationId": "CreateAccountingCustomer",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomerRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerDto"
                }
              }
            }
          },
          "502": {
            "description": "Bad Gateway",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/accounting/customers/{customerId}": {
      "get": {
        "tags": [
          "Integrations - Accounting"
        ],
        "summary": "Get Customer",
        "description": "Gets the AccountingCustomer from the ThirdPartyConnection set as Tenant.AccountingConnectionCode. 404 for a user restricted to clients this customer is not mapped to.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetAccountingCustomerById",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "502": {
            "description": "Bad Gateway",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/accounting/customers/{customerId}/invoices": {
      "get": {
        "tags": [
          "Integrations - Accounting"
        ],
        "summary": "Get Invoices for Customer",
        "description": "Gets all invoices for a specific customer from the ThirdPartyConnection set as Tenant.AccountingConnectionCode. Pass 'status' to list only invoices in one status; the platform does the filtering, so the window and total are of the matching invoices. 404 for a user restricted to clients this customer is not mapped to.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetInvoicesByCustomer",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/InvoiceStatus"
            },
            "x-order": 200
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceDtoPagedResult"
                }
              }
            }
          },
          "502": {
            "description": "Bad Gateway",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/accounting/invoices/{invoiceId}/pdf": {
      "get": {
        "tags": [
          "Integrations - Accounting"
        ],
        "summary": "Download Invoice PDF",
        "description": "Downloads the PDF for an invoice from the accounting platform. Only available when IsPdfAvailable is true on the invoice. Use the optional 'disposition' parameter: 'attachment' (default) prompts a file download, 'inline' displays the PDF in the browser.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetInvoicePdf",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "disposition",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/accounting/nominalcodes": {
      "get": {
        "tags": [
          "Integrations - Accounting"
        ],
        "summary": "List Nominal Codes",
        "description": "Lists the nominal codes an invoice line can be coded to, from the connected accounting platform. Accounts that income cannot be posted to are excluded, as is any account the platform has archived. Returns 501 if the platform does not support this feature.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "GetNominalCodes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NominalCodeDto"
                  }
                }
              }
            }
          },
          "501": {
            "description": "Not Implemented"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/clients": {
      "get": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "List AML Clients",
        "description": "Lists clients (accounts) from the AML platform with pagination. When a search term is provided, searches across client name, reference, and contact details.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetAmlClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/AmlClientSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across AML client name, reference, or contact details (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "acme"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmlClientDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Create AML Client",
        "description": "Creates a new client (account) in the AML platform. The platform is the ThirdPartyConnection.Code set in Tenant.AmlConnectionCode\n\nRequires: Update on Clients.",
        "operationId": "CreateAmlClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAmlClientRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmlClientDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/clients/{clientId}": {
      "get": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Get AML Client",
        "description": "Gets a specific client (account) from the AML platform by ID\n\nRequires: ViewAll on Clients.",
        "operationId": "GetAmlClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmlClientDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/clients/{clientId}/risk-assessments": {
      "get": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Get AML Risk Assessments",
        "description": "Gets the risk assessments for a specific AML client from the AML platform\n\nRequires: ViewAll on Clients.",
        "operationId": "GetAmlRiskAssessments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/AmlClientSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmlRiskAssessmentDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Start AML Risk Assessment",
        "description": "Starts a new risk assessment for a specific AML client in the AML platform. Optionally attach a questionnaire template and copy the answers from an earlier risk assessment.\n\nRequires: Update on Clients.",
        "operationId": "StartAmlRiskAssessment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRiskAssessmentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmlRiskAssessmentDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/risk-assessment-templates": {
      "get": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "List AML Risk Assessment Templates",
        "description": "Lists questionnaire templates available for risk assessments in the AML platform\n\nRequires: ViewAll on Clients.",
        "operationId": "GetAmlRiskAssessmentTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CodeAndNameDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/clients/{clientId}/contacts": {
      "post": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Add AML Contact",
        "description": "Adds a contact to an existing AML client (account) in the AML platform\n\nRequires: Update on Clients.",
        "operationId": "AddAmlContact",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddAmlContactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmlContactDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/clients/{clientId}/contacts/{contactId}": {
      "get": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Get AML Contact",
        "description": "Gets a specific contact from an AML client in the AML platform\n\nRequires: ViewAll on Clients.",
        "operationId": "GetAmlContact",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmlContactDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Update AML Contact",
        "description": "Updates a contact in the AML platform\n\nRequires: Update on Clients.",
        "operationId": "UpdateAmlContact",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAmlContactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmlContactDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/onboarding-levels": {
      "get": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "List AML Onboarding Levels",
        "description": "Lists onboarding levels configured in the AML platform\n\nRequires: ViewAll on Clients.",
        "operationId": "GetAmlOnboardingLevels",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AmlOnboardingLevelDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/mail-templates": {
      "get": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "List AML Mail Templates",
        "description": "Lists mail templates from the AML platform, filtered by type (ONBOARDING or CLIENT_ONBOARDING)\n\nRequires: ViewAll on Clients.",
        "operationId": "GetAmlMailTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 201
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AmlMailTemplateDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/clients/{clientId}/contacts/{contactId}/onboarding-report": {
      "put": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Create Onboarding Report",
        "description": "Creates an onboarding report for a contact in the AML platform. With replaceExisting, cancels the contact's current report first (used to retry a stuck one).\n\nRequires: Update on Clients.",
        "operationId": "CreateOnboardingReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOnboardingReportRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Cancel Onboarding Report",
        "description": "Cancels the contact's onboarding report in the AML platform\n\nRequires: Update on Clients.",
        "operationId": "CancelOnboardingReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/aml/clients/{clientId}/contacts/{contactId}/onboarding-url": {
      "get": {
        "tags": [
          "Integrations - AML"
        ],
        "summary": "Get Onboarding URL",
        "description": "Gets the onboarding URL for a contact. Only available while the contact's request is still open; a completed or dead request has no link.\n\nRequires: ViewAll on Clients.",
        "operationId": "GetAmlOnboardingUrl",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmlOnboardingUrlResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/mtd/figure-mappings/{incomeSourceType}": {
      "get": {
        "tags": [
          "Making Tax Digital"
        ],
        "summary": "Get Figure Mapping",
        "description": "Returns the practice's remembered spreadsheet mapping for one income source type — how their bookkeeping category labels map onto the quarterly-update figure fields. The mapping entries are stored verbatim for the importing form; the server does not interpret them. 404 before any import has saved one.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "GetMtdFigureMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "incomeSourceType",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MtdIncomeSourceType"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdFigureMappingDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Making Tax Digital"
        ],
        "summary": "Save Figure Mapping",
        "description": "Saves the practice's remembered spreadsheet mapping for one income source type, replacing any previous one — there is exactly one remembered mapping per source type.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "SaveMtdFigureMapping",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "incomeSourceType",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MtdIncomeSourceType"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMtdFigureMappingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdFigureMappingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/mtd/verification": {
      "get": {
        "tags": [
          "Making Tax Digital"
        ],
        "summary": "List Authorisations To Verify",
        "description": "Lists every Making Tax Digital authorisation the practice's clients require, with the status held, what HMRC last confirmed, and whether enough is known about the client to ask HMRC at all. Clients that cannot be checked are missing a National Insurance number or VAT number, or the postcode or registration date that proves it.\n\nRequires: ViewAll on MakingTaxDigitalIncomeTax.",
        "operationId": "getMtdVerificationSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MtdVerificationItemDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/mtd/verification/run": {
      "post": {
        "tags": [
          "Making Tax Digital"
        ],
        "summary": "Check All Authorisations With HMRC",
        "description": "Queues a check with HMRC for every client authorisation the practice holds enough detail to ask about. Runs in the background — poll the summary for results. Clients missing a National Insurance number, VAT number or known fact are skipped rather than queued, and the response reports how many that was.\n\nRequires: Update on MakingTaxDigitalIncomeTax.",
        "operationId": "runMtdVerificationSweep",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MtdVerificationSweepResultDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "MakingTaxDigitalIncomeTax",
            "permission": "Update"
          }
        ]
      }
    },
    "/mailinglist/subscribe": {
      "post": {
        "tags": [
          "Marketing"
        ],
        "summary": "Subscribe to Mailing List",
        "operationId": "SubscribeToMailingList",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MailingListSubscriptionDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IResult"
                }
              }
            }
          }
        }
      }
    },
    "/tenants/{tenant}/practice-documents": {
      "get": {
        "tags": [
          "Media Library - Documents"
        ],
        "summary": "List PracticeDocuments",
        "description": "Lists all PracticeDocuments for the given tenant.\n\nRequires: ViewAll on PracticeDocuments.",
        "operationId": "ListPracticeDocuments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/PracticeDocumentSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeDocumentDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDocuments",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Media Library - Documents"
        ],
        "summary": "Create Practice Document",
        "description": "Uploads a new document to the practice document library\n\nRequires: Create on PracticeDocuments.",
        "operationId": "CreatePracticeDocument",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file",
                  "name"
                ],
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "name": {
                  "style": "form"
                },
                "description": {
                  "style": "form"
                },
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDocuments",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice-documents/{code}": {
      "get": {
        "tags": [
          "Media Library - Documents"
        ],
        "summary": "Get PracticeDocument",
        "description": "Gets a PracticeDocument for the specified tenant.\n\nRequires: ViewAll on PracticeDocuments.",
        "operationId": "GetPracticeDocument",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeDocumentDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDocuments",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Media Library - Documents"
        ],
        "summary": "Update PracticeDocument",
        "description": "Updates a PracticeDocument for the specified tenant.\n\nRequires: Update on PracticeDocuments.",
        "operationId": "UpdatePracticeDocument",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePracticeDocumentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDocuments",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Media Library - Documents"
        ],
        "summary": "Delete PracticeDocument",
        "description": "Deletes a practice document and its stored file\n\nRequires: Delete on PracticeDocuments.",
        "operationId": "DeletePracticeDocument",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDocuments",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice-documents/{code}/content": {
      "get": {
        "tags": [
          "Media Library - Documents"
        ],
        "summary": "Streams practice document content with ETag caching and the original file name.\nA matching If-None-Match returns 304 without touching blob storage.",
        "description": "Streams the practice document file content\n\nRequires: ViewAll on PracticeDocuments.",
        "operationId": "StreamPracticeDocumentContent",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "304": {
            "description": "Not Modified"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDocuments",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/media-library/images": {
      "get": {
        "tags": [
          "Media Library - Images"
        ],
        "summary": "List ImageAssets",
        "description": "Lists all ImageAssets for the given tenant.\n\nRequires: ViewAll on DesignThemes.",
        "operationId": "ListImageAssets",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ImageAssetSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageAssetDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Media Library - Images"
        ],
        "summary": "Create ImageAsset",
        "description": "Requires: Create on DesignThemes.",
        "operationId": "CreateImageAsset",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file",
                  "name"
                ],
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "name": {
                  "style": "form"
                },
                "description": {
                  "style": "form"
                },
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageAssetDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/media-library/images/{code}": {
      "get": {
        "tags": [
          "Media Library - Images"
        ],
        "summary": "Get ImageAsset",
        "description": "Gets a ImageAsset for the specified tenant.\n\nRequires: ViewAll on DesignThemes.",
        "operationId": "GetImageAsset",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageAssetDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Media Library - Images"
        ],
        "summary": "Update ImageAsset",
        "description": "Updates a ImageAsset for the specified tenant.\n\nRequires: Update on DesignThemes.",
        "operationId": "UpdateImageAsset",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateImageAssetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageAssetDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Media Library - Images"
        ],
        "summary": "Delete ImageAsset",
        "description": "Deletes a ImageAsset for the specified tenant.\n\nRequires: Delete on DesignThemes.",
        "operationId": "DeleteImageAsset",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/media-library/images/{code}/content": {
      "get": {
        "tags": [
          "Media Library - Images"
        ],
        "summary": "Streams image content with ETag caching.\nA matching If-None-Match returns 304 without touching blob storage.",
        "description": "Requires: ViewAll on DesignThemes.",
        "operationId": "StreamImageContent",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "304": {
            "description": "Not Modified"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "DesignThemes",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/external-meeting-notes": {
      "get": {
        "tags": [
          "Meeting Notes - Unmatched"
        ],
        "summary": "List Unmatched Meeting Notes",
        "description": "Meeting notes from a note taker that matched no client, or more than one, newest first. Pass status=Ignored for the ignored ones, and connectionCode for one connection's. Notes on a client are not listed.\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "ListExternalMeetingNotes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ExternalMeetingNoteSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Unmatched (the default) or Ignored",
            "schema": {
              "enum": [
                "Unmatched",
                "Ignored",
                "Matched"
              ],
              "type": "string",
              "example": "Ignored"
            }
          },
          {
            "name": "connectionCode",
            "in": "query",
            "description": "Only notes from this connection",
            "schema": {
              "type": "string",
              "example": "granola_ab12cd34ef56"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalMeetingNoteDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/external-meeting-notes/{code}": {
      "get": {
        "tags": [
          "Meeting Notes - Unmatched"
        ],
        "summary": "Get Unmatched Meeting Note",
        "description": "One note: an unmatched (or ignored) one with its summary, and its transcript if the connection imports them, fetched from the note taker now for review before filing, nothing stored; or one on a client, with its client and task and the meeting's own summary.\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "GetExternalMeetingNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalMeetingNoteDetailDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "patch": {
        "tags": [
          "Meeting Notes - Unmatched"
        ],
        "summary": "Patch Meeting Note",
        "description": "Changes where a meeting note from a note taker stands, following JSON Merge Patch: send only the fields to\nchange; a field left out is not touched.\n\n**clientCode**: a client code files an unmatched note on that client (its summary, and its transcript if the\nconnection imports them, are fetched from the note taker now), or moves a matched note to that client,\nkeeping the meeting and taking off any contacts the new client does not have. Null takes a matched note off\nits client and puts it back on the Unmatched list; any edits made to the meeting in Sodium are lost.\n\n**taskCode**: links a matched note to one of its client's tasks, or null removes the link. A task needs a client:\nsend it with a clientCode, or on a note already on a client. Moving a note to another client removes the link\nunless a task of the new client is sent with it.\n\n**isIgnored**: true ignores the note, so no look-up or webhook offers it again (a matched note comes off its\nclient first); false puts an ignored note back on the Unmatched list. Cannot be null, and an ignored note\ncannot be sent a client or task.\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "PatchExternalMeetingNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchExternalMeetingNoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalMeetingNoteDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/contacts/{contact}/messages": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Contact Messages",
        "description": "Returns the contact's SMS and WhatsApp messages, newest first (offset and limit; the order is fixed): every message in the conversations matched to the contact. Each carries its conversation's code and number; reply on the conversation. A user who can see only some clients gets a 404 unless the contact is on one of them.\n\nRequires: ViewAll on Messaging.",
        "operationId": "ListContactMessages",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "contact",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingMessageDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/messages": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Client Messages",
        "description": "Returns the client's SMS and WhatsApp messages, newest first (offset and limit; the order is fixed): every message in the conversations matched to the client, or to one of its contacts. Each carries its conversation's code, number and contact. search keeps only the messages whose text contains it, in any case (at most 200 characters; blank is no search); totalCount then counts the matches.\n\nRequires: ViewAll on Messaging.",
        "operationId": "ListClientMessages",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingMessageDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Send Client Message",
        "description": "Sends an SMS or WhatsApp message from the practice's number to one of the client's numbers or one of its contacts' (matched by phone lookup key; any other number is a 400). Free text (body), on WhatsApp a template (whatsAppTemplateId + contentVariables, sent as its live version), or a practice text template (templateCode: rendered here for the client and the contact holding the number, and sent as free text; 400 when it does not exist), exactly one. The message is stored at once from the Messaging Service's answer and returned as 201; its delivery status then follows from the service's events. A provider refusal is still a 201, with status Failed and errorCode/errorMessage. The conversation is matched to the client (and to the contact when one of the client's contacts holds the number) unless it is already matched. 409 when messaging is off or not set up, when the number has opted out, or for WhatsApp free text more than 24 hours after the recipient's last WhatsApp message (send a template), or for a WhatsApp template Meta has not approved any version of (messaging_whatsapp_template_not_approved); the service's text is passed through. 503 when the service or Twilio is unavailable.\n\nRequires: Create on Messaging.",
        "operationId": "SendClientMessage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendClientMessagingMessageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingMessageDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/messaging/read": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Mark Client Messaging Read",
        "description": "Marks every conversation the client's messages show read for the whole practice (its own, and its contacts'), and clears their message notifications from everyone's bell. Nothing changes for one already read. Reading the messages (GET) never does this.\n\nRequires: ViewAll on Messaging.",
        "operationId": "MarkClientMessagingRead",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{client}/messaging/recipients": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Client Messaging Recipients",
        "description": "Returns the numbers a message from this client can go to, one per number however it was typed: the client's own numbers first, then its contacts', then numbers matched to it by hand that are on no record (holder null). Each has who holds it, its conversation (code, WhatsApp window, last message) when one is matched to the client or its contacts, and the channels it has opted out of, read from the Messaging Service on every call; optedOutChannels is null when the service could not be read.\n\nRequires: Create on Messaging.",
        "operationId": "ListClientMessagingRecipients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 1
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessagingRecipientDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "Get Practice Messaging",
        "description": "Returns the practice's SMS and WhatsApp messaging: its status (Unavailable, Off, SettingUp, AwaitingNumber, Active), who switched it on and when, the numbers it sends from, and its quiet hours for automatic texts (null while messaging is off). Never sets anything up. When the Messaging Service is unreachable it still answers, with isServiceAvailable false and no senders.\n\nRequires: ViewAll on Messaging.",
        "operationId": "GetPracticeMessaging",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeMessagingDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Enable Messaging",
        "description": "Switches messaging on for the practice: its messaging account is found or created through Account Hub and set up in the Messaging Service. Safe to repeat, and repeating finishes a switch-on that failed part-way (status SettingUp). 409 while messaging is switched off in this environment, or Sodium has not allowed the practice to use it (messaging_not_allowed); 503 when the Messaging Service is unavailable, after which the practice stays SettingUp.\n\nRequires: Admin on Messaging.",
        "operationId": "EnableMessaging",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeMessagingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/prices": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "Get Messaging Prices",
        "description": "What messaging costs the practice (pence, ex VAT): the number's monthly price, a block of credits and the credits in it, and the credits a send costs. The practice's own prices once its messaging account is set up, else the defaults, so they can be shown before it applies for a number. 409 while messaging is switched off in this environment; 503 when the Messaging Service is unavailable.\n\nRequires: ViewAll on Messaging.",
        "operationId": "GetMessagingPrices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingCreditPricesDto"
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/available-numbers": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Available Messaging Numbers",
        "description": "UK mobile numbers the practice may choose from for its number application, optionally containing some digits (limit at most 30). Nothing is reserved by looking. 409 while the practice's messaging is not set up.\n\nRequires: Admin on Messaging.",
        "operationId": "ListMessagingAvailableNumbers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "contains",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessagingAvailableNumberDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/number-application": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "Get Messaging Number Application",
        "description": "The practice's application for its own UK mobile number: its status, the details as submitted, the reviewer's reasons when turned down, and the number once bought. When the practice has not applied the status is null and the details are prefilled from the practice record and the signed-in user. 409 while the practice's messaging is not set up.\n\nRequires: Admin on Messaging.",
        "operationId": "GetMessagingNumberApplication",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingNumberApplicationDto"
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      },
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Apply For Messaging Number",
        "description": "Applies for the practice's own UK mobile number with the business, address and representative given: the Messaging Service makes and submits the regulatory bundle for Twilio's review, and buys the number on approval. agreedToCosts must be true (the applicant agrees to the number's monthly price and to paying for the credits the practice buys). 400 with the fields when the details are refused; 409 billing_mandate_required without a Direct Debit; 409 unless the practice is awaiting a number, or while an application is already with the reviewer.\n\nRequires: Admin on Messaging.",
        "operationId": "ApplyForMessagingNumber",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyForMessagingNumberRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingNumberApplicationDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/number-application/withdraw": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Withdraw Messaging Number Application",
        "description": "Withdraws the practice's application for its own number while it is sent, in review, or approved with no number bought yet. The provider's review may still finish; an approval can then be reused. Returns the practice's messaging, with no application. 409 when there is no application to withdraw (none, or decided).\n\nRequires: Admin on Messaging.",
        "operationId": "WithdrawMessagingNumberApplication",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeMessagingDto"
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/number-application/reuse": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Reuse Messaging Number Application",
        "description": "Gets the practice a number at once with an earlier application's approved details (the number application read's reusable): a new application, approved straight away, then the number bought. The details cannot be changed; a change is a fresh application. agreedToCosts must be true, as for a fresh application. 409 billing_mandate_required without a Direct Debit; 409 unless the practice is awaiting a number and the details are still approved; 404 for an application the practice does not have.\n\nRequires: Admin on Messaging.",
        "operationId": "ReuseMessagingNumberApplication",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReuseMessagingNumberApplicationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingNumberApplicationDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/number/cancel": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Cancel Messaging Number",
        "description": "Cancels the practice's own messaging number: it is released to the provider straight away, clients can no longer text it, and after 10 days it may be given to someone else. Conversations and messages stay. Returns the practice's messaging, awaiting a number, from which it can apply again. 409 when the practice has no number of its own.\n\nRequires: Admin on Messaging.",
        "operationId": "CancelMessagingNumber",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeMessagingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/quiet-hours": {
      "put": {
        "tags": [
          "Messaging"
        ],
        "summary": "Update Messaging Quiet Hours",
        "description": "Replaces the practice's quiet hours for automatic texts: whether they are on, and when they start and end (UK time; the end is earlier than the start for a window that crosses midnight). A text a workflow step would send automatically inside them waits until they end; a step sent by hand goes at once. Returns the quiet hours as saved. 400 when a time is missing or not a time, or the start equals the end (on end); 409 messaging_not_set_up when the practice has not switched messaging on.\n\nRequires: Admin on Messaging.",
        "operationId": "UpdateMessagingQuietHours",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMessagingQuietHoursRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingQuietHoursDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/text-wordings": {
      "put": {
        "tags": [
          "Messaging"
        ],
        "summary": "Update Messaging Text Wordings",
        "description": "Replaces the practice's wording for the text a client send step (document request, document approval, client confirmation, form, CIS payments) adds to its email when the step asks for one, one per kind of request, and for the chase's text when the practice texts its chases; read on the practice's messaging as textWordings. Liquid, with {{ Url }} the recipient's own link (the portal's address in the chase's, which also has {{ Outstanding }}, \"3 things\"). Returns the wordings as saved. 400 when a wording is empty, longer than 500 characters, or has no {{ Url }}; 409 messaging_not_set_up when the practice has not switched messaging on.\n\nRequires: Admin on Messaging.",
        "operationId": "UpdateMessagingTextWordings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMessagingTextWordingsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingTextWordingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/request-text-routing": {
      "put": {
        "tags": [
          "Messaging"
        ],
        "summary": "Update Messaging Request Text Routing",
        "description": "Replaces how the practice's request texts (the texts client send steps add to their emails) and chase texts choose between WhatsApp and SMS, read on the practice's messaging as requestTextRouting: SmsOnly; KnownNumbers (the default: WhatsApp to a number known to be on WhatsApp when the kind's WhatsApp template has an approved version and WhatsApp is connected; SMS otherwise); or TryWhatsAppFirst (as KnownNumbers, and a number never tried on WhatsApp gets one WhatsApp attempt, the SMS following when the person is not on WhatsApp, after which the number stays on SMS). Decided per number when each text goes. Returns the routing as saved. 400 when routing is missing or not one of those; 409 messaging_not_set_up when the practice has not switched messaging on.\n\nRequires: Admin on Messaging.",
        "operationId": "UpdateMessagingRequestTextRouting",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMessagingRequestTextRoutingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingRequestTextRoutingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/credits": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "Get Messaging Credits",
        "description": "The practice's messaging credits: the balance (one SMS segment or one WhatsApp message costs one credit), the automatic top-up and low-credit alert, and the prices it pays. 409 while the practice's messaging is not set up.\n\nRequires: ViewAll on Messaging.",
        "operationId": "GetMessagingCredits",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingCreditsDto"
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/credits/purchases": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Messaging Credit Purchases",
        "description": "The practice's credit purchases, newest first (offset and limit; limit=0 returns the count alone): bought by someone in the practice, or by the automatic top-up. 409 while the practice's messaging is not set up.\n\nRequires: ViewAll on Messaging.",
        "operationId": "ListMessagingCreditPurchases",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingCreditPurchaseDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Purchase Messaging Credits",
        "description": "Buys blocks of messaging credits at the practice's block price, added to the balance at once and to the next invoice. Credits never expire and are not refunded. Make requestId once per purchase: sending it again returns the first purchase and buys nothing. 400 for a block count outside 1 to the most one purchase may buy; 409 billing_mandate_required without a Direct Debit, messaging_not_allowed when Sodium has not allowed messaging, or while the practice's messaging is not set up; 503 when Account Hub or the Messaging Service is unavailable.\n\nRequires: Admin on Messaging.",
        "operationId": "PurchaseMessagingCredits",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PurchaseMessagingCreditsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingCreditPurchaseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/credits/settings": {
      "put": {
        "tags": [
          "Messaging"
        ],
        "summary": "Update Messaging Credit Settings",
        "description": "Replaces the practice's automatic top-up and low-credit alert (null switches either off) and returns the credits. Every number is positive and the monthly cap at least one top-up's blocks, else 400. Switching automatic top-up on from off needs a Direct Debit (409 billing_mandate_required) and Sodium's permission (409 messaging_not_allowed); changing it, switching it off or the alert alone does not.\n\nRequires: Admin on Messaging.",
        "operationId": "UpdateMessagingCreditSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMessagingCreditSettingsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingCreditsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/whatsapp/embedded-signup": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "Get WhatsApp Embedded Signup",
        "description": "Sodium's values for opening Meta's WhatsApp Embedded Signup on the settings page: the Meta app ID, the configuration ID and Twilio's Partner Solution ID. The same for every practice. 404 while WhatsApp cannot be connected here yet; 409 while messaging is switched off in this environment.\n\nRequires: Admin on Messaging.",
        "operationId": "GetMessagingWhatsAppEmbeddedSignup",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingWhatsAppEmbeddedSignupDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/whatsapp": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Connect WhatsApp",
        "description": "Connects a number to WhatsApp once Meta's Embedded Signup has finished, with the WhatsApp Business Account it created and the display name: the practice's own SMS number, or address, a number it already has. Returns the practice's messaging, whatsApp Connecting: the number becomes the WhatsApp sender when Meta puts it online (minutes, at most 72 hours), or the connection fails with Meta's reasons; the user who connected is told either way. 400 for an address that cannot be connected, or when Twilio refuses (its reason in the message); 409 messaging_no_sender with no address unless the practice is Active with its own number, billing_mandate_required with an address and no Direct Debit, messaging_whatsapp_not_configured while WhatsApp cannot be connected here yet, or when it is connecting or connected already.\n\nRequires: Admin on Messaging.",
        "operationId": "ConnectMessagingWhatsApp",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectMessagingWhatsAppRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeMessagingDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      },
      "delete": {
        "tags": [
          "Messaging"
        ],
        "summary": "Disconnect WhatsApp",
        "description": "Disconnects the practice's WhatsApp: its sender is deleted and the number no longer sends or receives WhatsApp messages; conversations and messages stay. Safe to repeat. The notice says what to do before connecting the number again (turn off two-step verification for it in WhatsApp Manager). 409 while the practice's messaging is not set up.\n\nRequires: Admin on Messaging.",
        "operationId": "DisconnectMessagingWhatsApp",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeWhatsAppDisconnectedDto"
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/do-not-text": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Do Not Text Numbers",
        "description": "Every number on the practice's do-not-text list, the most recently added first: for each channel (sms, whatsApp) whether messages are stopped, how (Stop: the client replied STOP on that channel; Practice: someone in the practice added it) and when, with the contacts whose mobile it is. Read from the Messaging Service on every call. 409 messaging_not_set_up while the practice's messaging is not set up; 503 when the Messaging Service is unavailable.\n\nRequires: Admin on Messaging.",
        "operationId": "ListMessagingDoNotText",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessagingDoNotTextNumberDto"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice/messaging/do-not-text/{number}": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "Get Do Not Text Number",
        "description": "One number's place on the practice's do-not-text list: each channel's entry (null when that channel is not stopped; both null when the number is not on the list) and the contacts whose mobile it is. Any format of number is read (07700 900123, +447700900123 escaped as %2B447700900123). 400 for a number that cannot be read; 409 messaging_not_set_up while the practice's messaging is not set up; 503 when the Messaging Service is unavailable.\n\nRequires at least one of: ViewAll on Contacts or Admin on Messaging.",
        "operationId": "GetMessagingDoNotText",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingDoNotTextNumberDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "Contacts",
              "permission": "ViewAll"
            },
            {
              "entity": "Messaging",
              "permission": "Admin"
            }
          ]
        ]
      },
      "put": {
        "tags": [
          "Messaging"
        ],
        "summary": "Add Do Not Text Number",
        "description": "Puts the number on the practice's do-not-text list for both SMS and WhatsApp, keeping an entry a client's STOP made; workflow steps, request and chase texts and the Messages page then send it nothing. Safe to repeat. Returns the number as it now stands. Contact editors may add a number a contact holds; a number on no contact needs Messaging Admin (403). 400 for a number that cannot be read; 409 messaging_not_set_up while the practice's messaging is not set up; 503 when the Messaging Service is unavailable.\n\nRequires at least one of: Update on Contacts or Admin on Messaging.",
        "operationId": "AddMessagingDoNotText",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingDoNotTextNumberDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "Contacts",
              "permission": "Update"
            },
            {
              "entity": "Messaging",
              "permission": "Admin"
            }
          ]
        ]
      },
      "delete": {
        "tags": [
          "Messaging"
        ],
        "summary": "Remove Do Not Text Number",
        "description": "Takes the number off the practice's do-not-text list for both SMS and WhatsApp, however each was added; 204 whether or not it was on it. A client who replied STOP by text stays blocked by the mobile networks until they text START, so removing that entry only lets WhatsApp through. Contact editors may remove a number a contact holds; a number on no contact needs Messaging Admin (403). 400 for a number that cannot be read; 409 messaging_not_set_up while the practice's messaging is not set up; 503 when the Messaging Service is unavailable.\n\nRequires at least one of: Update on Contacts or Admin on Messaging.",
        "operationId": "RemoveMessagingDoNotText",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "Contacts",
              "permission": "Update"
            },
            {
              "entity": "Messaging",
              "permission": "Admin"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/messaging/conversations": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Messaging Conversations",
        "description": "Returns the practice's conversations in one view, newest activity first (offset and limit; the order is fixed; limit=0 returns the count alone). view=ToSort: matched to no contact and no client and not dismissed; All (the default): every conversation not dismissed; Matched: those matched to a contact or a client and not dismissed; Dismissed: the dismissed ones. unread=true keeps only the unread ones (the nav badge is unread=true&limit=0). Each has its message count, newest message and unread flag, and an ambiguous unmatched one lists the contacts and clients holding its number. A user who can see only some clients gets All and Matched only, holding the conversations on those clients (directly or through the contact); ToSort and Dismissed are a 403 for them.\n\nRequires: ViewAll on Messaging.",
        "operationId": "ListMessagingConversations",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "unread",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "x-order": 400
          },
          {
            "name": "view",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/MessagingConversationView"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingConversationDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/conversations/{code}": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "Get Messaging Conversation",
        "description": "Returns one conversation with a page of its messages, newest first (offset and limit). A user who can see only some clients gets a 404 unless the conversation is on one of them, directly or through its contact.\n\nRequires: ViewAll on Messaging.",
        "operationId": "GetMessagingConversation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingConversationDetailDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/conversations/{code}/read": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Mark Messaging Conversation Read",
        "description": "Marks the conversation read for the whole practice (hasUnread false, lastReadDate now) and clears its message notifications from everyone's bell. Nothing changes when it is already read. Reading the conversation (GET) never does this. A user who can see only some clients gets a 404 unless the conversation is on one of them.\n\nRequires: ViewAll on Messaging.",
        "operationId": "MarkMessagingConversationRead",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/conversations/{code}/messages": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Send Messaging Conversation Message",
        "description": "Replies on the conversation, to its number, whether or not it is matched. Free text (body), on WhatsApp a template (whatsAppTemplateId + contentVariables, sent as its live version), or a practice text template (templateCode: rendered here for the conversation's client and contact and sent as free text; 400 when it does not exist), exactly one; the conversation's whatsAppWindowClosesAt says when free text stops being allowed. The message is stored at once from the Messaging Service's answer and returned as 201; a provider refusal is still a 201 with status Failed. 409 when messaging is off or not set up, when the number has opted out, for WhatsApp free text outside the 24-hour window, or for a WhatsApp template Meta has not approved any version of (messaging_whatsapp_template_not_approved), with the service's text; 404 for an unknown template id. 503 when the service or Twilio is unavailable. Sending marks the conversation read. A user who can see only some clients gets a 404 unless the conversation is on one of them.\n\nRequires: Create on Messaging.",
        "operationId": "SendMessagingConversationMessage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMessagingMessageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingMessageDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/messages/{messageId}/retry": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Retry Messaging Message",
        "description": "Sends a failed message again: an outbound message that is Failed or Undelivered goes to its conversation's number on the same channel with its stored content (the text as it was sent, or the WhatsApp template with its stored variables), as a new message from the current user, returned as 201. The failed message is unchanged. 409 for any other message (inbound, or not failed), when messaging is off or not set up, or for the service's refusals (messaging_opted_out: the number is on the do-not-text list for the channel; WhatsApp free text outside the 24-hour window); 503 when the service or Twilio is unavailable. A user who can see only some clients gets a 404 unless the message's conversation is on one of them.\n\nRequires: Create on Messaging.",
        "operationId": "RetryMessagingMessage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingMessageDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/messages/{messageId}/media/{index}": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "Get Messaging Message Media",
        "description": "Streams one of a message's attachments (index from 0, as the message lists its media) from the Messaging Service's copy, with its content type and length; the message's media entries carry this route as url once the copy exists. 404 until then, for an unknown message or index, and for a user who can see only some clients unless the message's conversation is on one of them. 409 when messaging is off or not set up; 503 when the service is unavailable.\n\nRequires: ViewAll on Messaging.",
        "operationId": "GetMessagingMessageMedia",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "index",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/message-statuses": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Messaging Message Statuses",
        "description": "Returns the live status of the messages asked for (messageIds, at most 20), read from the Messaging Service, with the code of the conversation each is on: a task's text steps show delivered and read with it, and link to the conversation. A message on a conversation the user may not see, one the service cannot find, and every one while the service cannot be read, is left out. Empty when messaging is not set up.\n\nRequires: ViewAll on Messaging.",
        "operationId": "ListMessagingMessageStatuses",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "messageIds",
            "in": "query",
            "required": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uuid"
              }
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessagingMessageStatusDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/whatsapp-templates": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Messaging WhatsApp Templates",
        "description": "Returns the practice's WhatsApp templates, from its own Twilio account through the Messaging Service. Each has a stable id (what a send's whatsAppTemplateId and a Send Text Message step name), its live version (the one sent: the last Meta approved, which may since be paused or disabled; null until one is) and its pending version (a change in Meta's review, or one Meta rejected; null when nothing waits), each with WhatsApp's approval status, and, with includeUses=true (the settings tab), usedBy: the workflow steps that send it (null without it, so the pickers skip that read). Reading the list is what makes an approved change the live version. Only a template whose live version is approved can be sent outside the 24-hour window. 409 when messaging is off or not set up; 503 when the service or Twilio is unavailable.\n\nRequires: Create on Messaging.",
        "operationId": "ListMessagingWhatsAppTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "includeUses",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessagingWhatsAppTemplateDto"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      },
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Create Messaging WhatsApp Template",
        "description": "Makes a WhatsApp template in the practice's own Twilio account and submits it to Meta for approval; returns it as submitted (the list shows Meta's review as it goes). 400 with field errors when one of Meta's rules is broken (friendlyName, language, category, body, samples, samples.{n}) or Twilio refuses; 409 messaging_no_whatsapp_sender until the practice's own number is connected to WhatsApp, or when messaging is off or not set up; 503 when the service or Twilio is unavailable.\n\nRequires: Admin on Messaging.",
        "operationId": "CreateMessagingWhatsAppTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessagingWhatsAppTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingWhatsAppTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/whatsapp-templates/{id}": {
      "put": {
        "tags": [
          "Messaging"
        ],
        "summary": "Update Messaging WhatsApp Template",
        "description": "Saves the whole draft of a WhatsApp template. Text, category and language unchanged from its newest version: only the name is saved and nothing goes to Meta. Otherwise the change is made and submitted to Meta as the pending version (replacing a change already waiting); the live version is not touched and keeps being sent until Meta approves the change. Safe to repeat. Returns the template, with usedBy. The same 400s and 409s as creating; 409 too when workflow steps send the template and the change alters how many placeholders it has (the message names them and says to make a new template instead); 404 for a template the practice does not have.\n\nRequires: Admin on Messaging.",
        "operationId": "UpdateMessagingWhatsAppTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessagingWhatsAppTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingWhatsAppTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      },
      "delete": {
        "tags": [
          "Messaging"
        ],
        "summary": "Delete Messaging WhatsApp Template",
        "description": "Deletes a WhatsApp template, both its versions, from the practice's own Twilio account; one already gone is done. Messages sent with it are kept. 409 while workflow steps send it (a workflow's Send Text Message step, or a task's not yet done or skipped; the message names them), or when messaging is off or not set up.\n\nRequires: Admin on Messaging.",
        "operationId": "DeleteMessagingWhatsAppTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/whatsapp-templates/{id}/pending": {
      "delete": {
        "tags": [
          "Messaging"
        ],
        "summary": "Discard Messaging WhatsApp Template Change",
        "description": "Discards the template's change waiting for Meta, or one Meta rejected (its pending version), and keeps the live version; nothing waiting is done already. 409 when the template has no live version (delete it instead), or when messaging is off or not set up; 404 for a template the practice does not have.\n\nRequires: Admin on Messaging.",
        "operationId": "DiscardMessagingWhatsAppTemplateChange",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/request-templates": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List Messaging Request Templates",
        "description": "Returns, for each kind of request text (DocumentRequest, DocumentApproval, ClientConfirmation, DataForm, CisPayments, Chase), the practice's standard WhatsApp template: its id (the same every time, derived from the practice and the kind), the template with its live version (the approved text, its button and what fills each placeholder) and any change waiting for Meta (null when the practice does not have it), and needsSetUp: whether setting up would create it (missing) or send Sodium's wording again (Meta disabled it). One read of the practice's WhatsApp templates. 409 when messaging is off or not set up; 503 when the service or Twilio is unavailable.\n\nRequires: ViewAll on Messaging.",
        "operationId": "ListMessagingRequestTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessagingRequestTemplateDto"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Set Up Messaging Request Templates",
        "description": "Set up WhatsApp templates: creates in the practice's own Twilio account, and submits to Meta as Utility templates in en_GB with Sodium's starting wording, each kind's template the practice lacks, and sends Sodium's wording again as a change for one whose live version Meta disabled with no change waiting. Safe to repeat: what exists is left as it is. Returns the six as they now stand; a kind the service refused stays needsSetUp. 409 messaging_no_whatsapp_sender until the practice's own number is connected to WhatsApp, or when messaging is off or not set up; 503 when the service or Twilio is unavailable.\n\nRequires: Admin on Messaging.",
        "operationId": "SetUpMessagingRequestTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessagingRequestTemplateDto"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/conversations/{code}/match": {
      "put": {
        "tags": [
          "Messaging"
        ],
        "summary": "Match Messaging Conversation",
        "description": "Matches the conversation to a contact, a client, or a contact on one of its clients, which takes it out of the To sort view and onto the client's messages. A match made here is kept: the next message from the number does not change it. 400 for an unknown code, or a contact not on the client; 403 for a user who can see only some clients.\n\nRequires: Update on Messaging.",
        "operationId": "MatchMessagingConversation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MatchMessagingConversationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingConversationDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Messaging"
        ],
        "summary": "Unmatch Messaging Conversation",
        "description": "Clears the conversation's contact and client, which puts it back in the To sort view (unless it was dismissed). It is not matched automatically again. 403 for a user who can see only some clients.\n\nRequires: Update on Messaging.",
        "operationId": "UnmatchMessagingConversation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingConversationDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/conversations/{code}/dismiss": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Dismiss Messaging Conversation",
        "description": "Takes the conversation out of the To sort and All views into Dismissed (spam, a wrong number), and marks it read. Its messages are kept, and it is not matched automatically while dismissed. A new message from the number brings it back. 403 for a user who can see only some clients.\n\nRequires: Update on Messaging.",
        "operationId": "DismissMessagingConversation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingConversationDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Messaging"
        ],
        "summary": "Undismiss Messaging Conversation",
        "description": "Brings a dismissed conversation back: into the To sort view when it has no contact and no client. 403 for a user who can see only some clients.\n\nRequires: Update on Messaging.",
        "operationId": "UndismissMessagingConversation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingConversationDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/conversations/{code}/tasks": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Link Messaging Conversation Task",
        "description": "Links a task to the conversation, as a task is linked to an email conversation; the conversation's taskAssociations lists it. Linking a task already linked changes nothing. Returns the task's code and name. 404 for an unknown task, and for a user who can see only some clients unless the conversation is on one of them.\n\nRequires: Update on Messaging.",
        "operationId": "LinkMessagingConversationTask",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkConversationTaskRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodeAndNameDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/conversations/{code}/tasks/{taskCode}": {
      "delete": {
        "tags": [
          "Messaging"
        ],
        "summary": "Unlink Messaging Conversation Task",
        "description": "Removes the task's link from the conversation; a task not linked is done. The task itself is unchanged. A user who can see only some clients gets a 404 unless the conversation is on one of them.\n\nRequires: Update on Messaging.",
        "operationId": "UnlinkMessagingConversationTask",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/templates": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "List MessagingTemplates",
        "description": "Lists all MessagingTemplates for the given tenant.\n\nRequires: Create on Messaging.",
        "operationId": "ListMessagingTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/MessagingTemplateSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingTemplateDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      },
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Create MessagingTemplate",
        "description": "Creates a new MessagingTemplate for the specified tenant.\n\nRequires: Admin on Messaging.",
        "operationId": "CreateMessagingTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMessagingTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/templates/{code}": {
      "get": {
        "tags": [
          "Messaging"
        ],
        "summary": "Get MessagingTemplate",
        "description": "Gets a MessagingTemplate for the specified tenant.\n\nRequires: Create on Messaging.",
        "operationId": "GetMessagingTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingTemplateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      },
      "put": {
        "tags": [
          "Messaging"
        ],
        "summary": "Update MessagingTemplate",
        "description": "Updates a MessagingTemplate for the specified tenant.\n\nRequires: Admin on Messaging.",
        "operationId": "UpdateMessagingTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMessagingTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      },
      "delete": {
        "tags": [
          "Messaging"
        ],
        "summary": "Delete MessagingTemplate",
        "description": "Deletes a MessagingTemplate for the specified tenant.\n\nRequires: Admin on Messaging.",
        "operationId": "DeleteMessagingTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/messaging/templates/{code}/render": {
      "post": {
        "tags": [
          "Messaging"
        ],
        "summary": "Render Messaging Template",
        "description": "Returns the template's text rendered for one recipient, as a send would render it now: for a conversation (its client and contact fill the tokens; an unmatched one only the practice and date tokens), or for a client and the number it goes to (the contact of the client holding that number fills the Contact tokens), or for nobody. A token with no value renders empty; nothing is HTML-encoded. 400 when to is not a number of the client or its contacts; 404 for an unknown template, client or conversation, or one a user who can see only some clients cannot see.\n\nRequires: Create on Messaging.",
        "operationId": "RenderMessagingTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderMessagingTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagingTemplateRenderDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      }
    },
    "/metadata/accounting-connection-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AccountingConnectionType",
        "description": "Retrieves metadata (such as the display name) for the AccountingConnectionType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAccountingConnectionType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/agent-authorisation-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AgentAuthorisationStatus",
        "description": "Retrieves metadata (such as the display name) for the AgentAuthorisationStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAgentAuthorisationStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/agent-authorisation-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AgentAuthorisationType",
        "description": "Retrieves metadata (such as the display name) for the AgentAuthorisationType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAgentAuthorisationType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/aml-contact-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AmlContactStatus",
        "description": "Retrieves metadata for the AmlContactStatus enum (onboarding/AML check status per contact).\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAmlContactStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/aml-risk-assessment-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AmlRiskAssessmentStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the AmlRiskAssessmentStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAmlRiskAssessmentStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/aml-risk-levels": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AmlRiskLevel",
        "description": "Retrieves metadata (such as the display name and colors) for the AmlRiskLevel enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAmlRiskLevel",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/aml-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AmlStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the AmlStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAmlStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/ai-activities": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AiActivity",
        "description": "Retrieves metadata (such as the display name) for the AiActivity enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAiActivity",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/ai-contexts": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AiContext",
        "description": "Retrieves metadata (such as the display name) for the AiContext enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAiContext",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/assignment-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AssignmentType",
        "description": "Retrieves metadata (such as the display name) for the AssignmentType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAssignmentType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/authentication-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "AuthenticationType",
        "description": "Retrieves metadata (such as the display name) for the AuthenticationType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetAuthenticationType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/billing-frequencies": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "BillingFrequency",
        "description": "Retrieves metadata (such as the display name) for the BillingFrequency enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetBillingFrequency",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/billing-schedule-display-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "BillingScheduleDisplayStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the BillingScheduleDisplayStatus enum shown on a client's billing schedule.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetBillingScheduleDisplayStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/billing-schedule-item-kinds": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "BillingScheduleItemKind",
        "description": "Retrieves metadata (such as the display name and colors) for the BillingScheduleItemKind enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetBillingScheduleItemKind",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/billing-timings": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "BillingTiming",
        "description": "Retrieves metadata for the BillingTiming enum (when a service is billed: in arrears, in advance, or when the work is done).\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetBillingTiming",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/setup-fee-billing-moments": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "SetupFeeBillingMoment",
        "description": "Retrieves metadata for the SetupFeeBillingMoment enum (when setup and catch-up fees are billed).\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetSetupFeeBillingMoment",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/cis-payments-collected-by": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "CisPaymentsCollectedBy",
        "description": "Retrieves metadata for the CisPaymentsCollectedBy enum (who enters a Collect CIS payments step's payments: the practice's staff or the client).\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetCisPaymentsCollectedBy",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/cis-unmatched-subcontractor-actions": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "CisUnmatchedSubcontractorAction",
        "description": "Retrieves metadata for the CisUnmatchedSubcontractorAction enum (what a Verify subcontractors step asks HMRC to do with a subcontractor it cannot match: verify at the higher rate, or return no number).\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetCisUnmatchedSubcontractorAction",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/tax-month-choices": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "TaxMonthChoice",
        "description": "Retrieves metadata for the TaxMonthChoice enum (which tax month a workflow step that works on one uses, relative to the task's due date), with the wording the step set-up shows.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetTaxMonthChoice",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/client-billing-line-item-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ClientBillingLineItemStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the ClientBillingLineItemStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetClientBillingLineItemStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/client-invoice-submission-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ClientInvoiceSubmissionStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the ClientInvoiceSubmissionStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetClientInvoiceSubmissionStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/client-association-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ClientAssociationType",
        "description": "Retrieves metadata (such as the display name) for the ClientAssociationType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetClientAssociationType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/client-contact-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ClientContactType",
        "description": "Retrieves metadata (such as the display name) for the ClientContactType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetClientContactType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/client-date-source-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ClientDateSourceType",
        "description": "Retrieves metadata for the ClientDateSourceType enum, indicating whether a recurring task uses a built-in key date or a tenant-defined custom field date.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetClientDateSourceType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/client-date-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ClientDateType",
        "description": "Retrieves metadata (such as the display name) for the ClientDateType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetClientDateType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/client-csv-target-fields": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ClientCsvTargetField",
        "description": "Retrieves metadata (such as the display name) for the ClientCsvTargetField enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetClientCsvTargetField",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/csv-import-match-fields": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "CsvImportMatchField",
        "description": "Retrieves metadata (such as the display name) for the CsvImportMatchField enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetCsvImportMatchField",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/client-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ClientStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the ClientStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetClientStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/client-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ClientType",
        "description": "Retrieves metadata (such as the display name) for the ClientType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetClientType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/company-status": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "CompanyStatus",
        "description": "Retrieves metadata (such as the display name) for the CompanyStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetCompanyStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/connection-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ConnectionStatus",
        "description": "Retrieves metadata (such as the display name) for the ConnectionStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetConnectionStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/content-block-categories": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ContentBlockCategory",
        "description": "Retrieves metadata (such as the display name) for the ContentBlockCategory enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetContentBlockCategory",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/custom-field-data-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "CustomFieldDataType",
        "description": "Retrieves metadata for the CustomFieldDataType enum, including display names for each custom field data type.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetCustomFieldDataType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/custom-field-entity-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "CustomFieldEntityType",
        "description": "Retrieves metadata for the CustomFieldEntityType enum, including display names for each entity type that supports custom fields.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetCustomFieldEntityType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/boolean-display-modes": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "BooleanDisplayMode",
        "description": "Retrieves metadata for the BooleanDisplayMode enum, including display mode options for Boolean fields.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetBooleanDisplayMode",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/field-display-widths": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "FieldDisplayWidth",
        "description": "Retrieves metadata for the FieldDisplayWidth enum, including preset width options for custom field and data form inputs.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetFieldDisplayWidth",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/background-image-positions": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "BackgroundImagePosition",
        "description": "Controls the positioning of a background image on PDF pages.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetBackgroundImagePosition",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/page-selections": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "PageSelection",
        "description": "Controls which pages a feature applies to in PDF documents.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetPageSelection",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/template-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "TemplateType",
        "description": "Retrieves metadata (such as the display name) for the TemplateType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetTemplateType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/theme-fonts": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ThemeFont",
        "description": "Retrieves metadata for the ThemeFont enum, including font family, fallback, and Google Font URL.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetThemeFont",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/days-before-or-after": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "DaysBeforeOrAfter",
        "description": "Retrieves metadata (such as the display name) for the DaysBeforeOrAfter enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetDaysBeforeOrAfter",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/data-form-answer-review-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "DataFormAnswerReviewStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the DataFormAnswerReviewStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetDataFormAnswerReviewStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/data-form-request-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "DataFormRequestStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the DataFormRequestStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetDataFormRequestStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/data-form-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "DataFormStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the DataFormStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetDataFormStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/document-request-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "DocumentRequestStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the DocumentRequestStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetDocumentRequestStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/document-request-item-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "DocumentRequestItemStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the DocumentRequestItemStatus enum: where one item on a document request stands.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetDocumentRequestItemStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/document-request-item-kinds": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "DocumentRequestItemKind",
        "description": "Retrieves metadata for the DocumentRequestItemKind enum: whether an item on a document request is a query or a document.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetDocumentRequestItemKind",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/due-date-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "DueDateType",
        "description": "How a recurring task's projected DueDate is calculated: offset from start, fixed annual date, or anchored to a client date.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetDueDateType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/email-broadcast-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "EmailBroadcastStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the EmailBroadcastStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetEmailBroadcastStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/email-broadcast-recipient-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "EmailBroadcastRecipientStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the EmailBroadcastRecipientStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetEmailBroadcastRecipientStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/broadcast-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "BroadcastStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the BroadcastStatus enum: the status of a bulk text, and of any broadcast in the Bulk Comms list.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetBroadcastStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/text-broadcast-recipient-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "TextBroadcastRecipientStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the TextBroadcastRecipientStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetTextBroadcastRecipientStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/filing-history-categories": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "FilingHistoryCategory",
        "description": "Retrieves metadata (such as the display name) for the FilingHistoryCategory enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetFilingHistoryCategory",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/fee-override-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "FeeOverrideType",
        "description": "Retrieves metadata (such as the display name) for the FeeOverrideType enum: the kinds of fee the Fee overrides report lists.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetFeeOverrideType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/holiday-adjustments": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "HolidayAdjustment",
        "description": "Retrieves metadata (such as the display name) for the HolidayAdjustment enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetHolidayAdjustment",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/hmrc-verification-results": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "HmrcVerificationResult",
        "description": "Retrieves metadata (such as the display name and colors) for the HmrcVerificationResult enum — what HMRC last said about an agent authorisation.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetHmrcVerificationResult",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/invoice-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "InvoiceStatus",
        "description": "Retrieves metadata (such as the display name) for the InvoiceStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetInvoiceStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/kpi-periods": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "KpiPeriod",
        "description": "Retrieves metadata (such as the display name) for the KpiPeriod enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetKpiPeriod",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/link-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "LinkType",
        "description": "Retrieves metadata (such as the display name and icon) for the LinkType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetLinkType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/marital-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "MaritalStatus",
        "description": "Retrieves metadata (such as the display name) for the MaritalStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetMaritalStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/month-day-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "MonthDayType",
        "description": "Retrieves metadata (such as the display name) for the MonthDayType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetMonthDayType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/nationalities": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "Nationality",
        "description": "Retrieves metadata (such as the display name) for the Nationality enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetNationality",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/permissions": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "Permission",
        "description": "Retrieves metadata for the Permission enum, including display names and descriptions of each permission level.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetPermission",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/permissible-entities": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "PermissibleEntity",
        "description": "Retrieves metadata for the PermissibleEntity enum, including display names of entities that can have permissions applied to them.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetPermissibleEntity",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/outbound-webhook-delivery-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "OutboundWebhookDeliveryStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the OutboundWebhookDeliveryStatus enum: where a webhook delivery stands.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetOutboundWebhookDeliveryStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/outbound-webhook-disabled-reasons": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "OutboundWebhookDisabledReason",
        "description": "Retrieves metadata (such as the display name and colors) for the OutboundWebhookDisabledReason enum: why a webhook is switched off.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetOutboundWebhookDisabledReason",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/platform-capabilities": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "PlatformCapability",
        "description": "Retrieves metadata for the PlatformCapability enum, including display names of capabilities that third-party platforms can provide.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetPlatformCapability",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/preset-date-ranges": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "PresetDateRange",
        "description": "Retrieves metadata for the PresetDateRange enum, including display names for preset date range options.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetPresetDateRange",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/pricing-bases": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "PricingBasis",
        "description": "Retrieves metadata for the PricingBasis enum, indicating whether a service's price is a flat amount per period or a rate multiplied by a quantity (per hour/day/unit).\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetPricingBasis",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/professional-bodies": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ProfessionalBody",
        "description": "Retrieves metadata (such as the display name) for the ProfessionalBody enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetProfessionalBody",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/engagement-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "EngagementStatus",
        "description": "Retrieves metadata (such as the display name) for the EngagementStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetEngagementStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/engagement-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "EngagementType",
        "description": "Retrieves metadata (such as the display name) for the EngagementType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetEngagementType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/recurrence-units": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "RecurrenceUnit",
        "description": "Retrieves metadata (such as the display name) for the RecurrenceUnit enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetRecurrenceUnit",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/recurring-task-occurrence-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "RecurringTaskOccurrenceStatus",
        "description": "Retrieves metadata (such as the display name, icon, and colors) for the RecurringTaskOccurrenceStatus enum - whether an occurrence of a recurring task is still to be created, has been created, or was deleted.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetRecurringTaskOccurrenceStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/role-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "RoleType",
        "description": "Retrieves metadata (such as the display name) for the RoleType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetRoleType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/service-pricing-modes": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ServicePricingMode",
        "description": "Retrieves metadata for the ServicePricingMode enum, indicating whether a service uses Revenue Range or Custom Tiers pricing.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetServicePricingMode",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/service-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ServiceStatus",
        "description": "Retrieves metadata (such as the display name, icon, and colors) for the ServiceStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetServiceStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/sodium-products": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "SodiumProduct",
        "description": "Retrieves metadata (the display name, description and logo) for the SodiumProduct enum - the other Sodium products a service can be powered by.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetSodiumProduct",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/sic-codes": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "SicCode",
        "description": "Retrieves metadata (such as the code and description) for the SicCode enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetSicCode",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/statutory-date-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "StatutoryDateType",
        "description": "How a recurring task's projected StatutoryDueDate is calculated: none, fixed annual date, or anchored to a client date.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetStatutoryDateType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/system-roles": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "SystemRole",
        "description": "Retrieves metadata (such as the display name) for the SystemRole enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetSystemRole",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/task-item-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "TaskItemStatus",
        "description": "Retrieves metadata (such as the display name, icon, and colors) for the TaskItemStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetTaskItemStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/tenant-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "TenantStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the TenantStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetTenantStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/time-billing-line-modes": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "TimeBillingLineMode",
        "description": "Retrieves metadata (such as the display name and description) for the TimeBillingLineMode enum — how billed time entries are shaped into billing line items.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetTimeBillingLineMode",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/work-type-rate-precedences": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "WorkTypeRatePrecedence",
        "description": "Retrieves metadata (such as the display name and description) for the WorkTypeRatePrecedence enum: which rate by type of work wins when a time entry's task category and its service both have one.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetWorkTypeRatePrecedence",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/time-entry-billing-states": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "TimeEntryBillingState",
        "description": "Retrieves metadata (such as the display name and colors) for the TimeEntryBillingState enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetTimeEntryBillingState",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/tenant-user-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "TenantUserStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the TenantUserStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetTenantUserStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/task-start-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "StartDateType",
        "description": "Retrieves metadata (such as the display name) for the StartDateType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetStartDateType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/task-date-bases": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "TaskDateBasis",
        "description": "Which date is the user-set driving date on a recurring task (StartDate or DueDate). Also used as a filter discriminator on task list queries.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetTaskDateBasis",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/user-activity-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "UserActivityType",
        "description": "Retrieves metadata (such as the display name) for the UserActivityType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetUserActivityType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/vat-rates": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "VatRate",
        "description": "Retrieves metadata (such as the display name) for the VatRate enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetVatRate",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/vat-reporting-periods": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "VatReportingPeriod",
        "description": "Retrieves metadata (such as the display name) for the VatReportingPeriod enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetVatReportingPeriod",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/vat-schemes": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "VatScheme",
        "description": "Retrieves metadata (such as the display name) for the VatScheme enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetVatScheme",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/smart-name-tokens": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "SmartNameToken",
        "description": "Retrieves the available tokens for smart name templates. Use {{ TokenName }} syntax in TaskNameTemplate or OutputNameTemplate (e.g. \"VAT Return - {{ ClientName }} - {{ Quarter.Label }} {{ Year.Current }}\"). Date tokens resolve from the context date: the occurrence start date for a recurring task name, the generation date for a document name. ClientName, ClientCode, and ClientInternalRef resolve from the associated client, and KeyDates.* tokens (e.g. {{ KeyDates.YearEnd }}) from that client's own key dates, and {{ Task.DueDate }} from the occurrence's due date - both task names only, since no other naming surface has them. Older single-word spellings still resolve but are no longer listed. Each token carries a sampleValue resolved against today, for the editors' live preview; pass ?locale= to have those formatted for the practice locale.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetSmartNameToken",
        "parameters": [
          {
            "name": "locale",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NameTokenDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/scheduled-send-statuses": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ScheduledSendStatus",
        "description": "Retrieves metadata (such as the display name and colors) for the ScheduledSendStatus enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetScheduledSendStatus",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/scheduled-send-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ScheduledSendType",
        "description": "Retrieves metadata (such as the display name) for the ScheduledSendType enum — the kinds of deferred send shown on the Scheduled tab.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetScheduledSendType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/week-day-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "WeekDayType",
        "description": "Retrieves metadata (such as the display name) for the WeekDayType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetWeekDayType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/workflow-email-sender-sources": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "WorkflowEmailSenderSource",
        "description": "Retrieves metadata for the WorkflowEmailSenderSource enum (which mailbox a workflow step's email is sent from).\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetWorkflowEmailSenderSource",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/workflow-step-assignment-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "WorkflowStepAssignmentType",
        "description": "Retrieves metadata (such as the display name) for the WorkflowStepAssignmentType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetWorkflowStepAssignmentType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/workflow-step-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "WorkflowStepType",
        "description": "Retrieves metadata (such as the display name) for the WorkflowStepType enum.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetWorkflowStepType",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnumMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/currencies": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "Currencies",
        "description": "Retrieves the ISO 4217 currencies a practice can be configured to bill in, with each one's symbol.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetCurrencies",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CurrencyMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/locales": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "Locales",
        "description": "Retrieves the locales a practice can be configured to format numbers and dates with.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetLocales",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LocaleMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/mtd-figure-targets/{incomeSourceType}": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "MTD Books Pull Targets",
        "description": "Retrieves the quarterly-update figure boxes a nominal account can be mapped into for one income source type, grouped and in HMRC's own field order. An income source type with no such vocabulary — foreign property, whose figures are reported per let — returns an empty list rather than an error.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetMtdFigureTargets",
        "parameters": [
          {
            "name": "incomeSourceType",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MtdIncomeSourceType"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MtdFigureTargetDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/outbound-webhook-event-types": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "Outbound Webhook Event Types",
        "description": "Retrieves the events a webhook can subscribe to, in the order the settings screen lists them.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetOutboundWebhookEventTypes",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OutboundWebhookEventTypeDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/metadata/third-party-platforms": {
      "get": {
        "tags": [
          "Metadata"
        ],
        "summary": "ThirdPartyPlatforms",
        "description": "Retrieves metadata about available third-party platforms and their capabilities.\n\nOpen to any signed-in user of the tenant: Static lookup lists (enum names, colours and descriptions), the same for every practice",
        "operationId": "GetThirdPartyPlatforms",
        "parameters": [
          {
            "name": "tenant",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ThirdPartyPlatformMetadata"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Static lookup lists (enum names, colours and descriptions), the same for every practice"
      }
    },
    "/tenants/{tenant}/notifications": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "List Notifications",
        "description": "The signed-in user's notifications, newest first. Page with `before` set to the last id received, or by `offset` for numbered pages, which also returns `totalCount`. An item the user may no longer see is returned redacted.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "ListNotifications",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "take",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 30
            },
            "x-order": 400
          },
          {
            "name": "view",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/NotificationView"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationFeedDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/summary": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "Get Notification Summary",
        "description": "The signed-in user's unseen and unread counts.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "GetNotificationSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationSummaryDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/seen": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Mark Notifications Seen",
        "description": "Marks every notification up to an id as seen, clearing the badge. Called when the bell opens. Items the user marked unread stay unseen.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "MarkNotificationsSeen",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarkNotificationsSeenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/{id}/read": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Mark Notification Read",
        "description": "Marks one notification as read, which also marks it seen and ends a mark as unread.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "MarkNotificationRead",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/{id}/unread": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Mark Notification Unread",
        "description": "Marks one notification as unread. It counts on the badge again, opening the bell does not clear it, and it is not emailed, until it is marked read.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "MarkNotificationUnread",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/read-all": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Mark All Notifications Read",
        "description": "Marks every unread notification in the inbox as read.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "MarkAllNotificationsRead",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/{id}/archive": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Archive Notification",
        "description": "Marks one notification as done, removing it from the inbox.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "ArchiveNotification",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/{id}/unarchive": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Unarchive Notification",
        "description": "Returns a done notification to the inbox.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "UnarchiveNotification",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/archive-read": {
      "post": {
        "tags": [
          "Notifications"
        ],
        "summary": "Archive Read Notifications",
        "description": "Marks every read notification in the inbox as done.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "ArchiveReadNotifications",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/preferences": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "Get Notification Preferences",
        "description": "Every notification type the signed-in user can receive, grouped by category, with whether each channel is on.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "GetNotificationPreferences",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationPreferencesDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      },
      "put": {
        "tags": [
          "Notifications"
        ],
        "summary": "Update Notification Preferences",
        "description": "Turns notification types on or off for the signed-in user, or (enabled null) returns them to their default. Types not listed keep their setting. Turning a type off stops new notifications; existing ones stay.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "UpdateNotificationPreferences",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/NotificationPreferenceUpdate"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/notifications/devices/{token}": {
      "put": {
        "tags": [
          "Notifications"
        ],
        "summary": "Register Notification Device",
        "description": "Registers the signed-in user's phone for push notifications in this tenant, or refreshes it. The phone app calls it for every tenant the user belongs to, at sign-in and whenever the platform gives it a new token. A token registered for someone else moves to this user: in this tenant, and, when the application identifies people across tenants, in every tenant.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "RegisterNotificationDevice",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationDeviceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      },
      "delete": {
        "tags": [
          "Notifications"
        ],
        "summary": "Remove Notification Device",
        "description": "Stops push notifications to the signed-in user's phone in this tenant (signing out). Removing a device that is not registered is not an error.\n\nOpen to any signed-in user of the tenant: The user's own inbox. What it may show is decided by the notification access policy",
        "operationId": "RemoveNotificationDevice",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The user's own inbox. What it may show is decided by the notification access policy"
      }
    },
    "/tenants/{tenant}/webhooks": {
      "get": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "List Webhooks",
        "description": "The practice's webhooks, oldest first (offset, and limit: 10 by default, at most 50), each with how its receiver has been answering. Never their secrets. Empty for a practice that has never created one. 409 while webhooks are not switched on in this environment. 503 when the Webhook Service is unavailable.\n\nRequires: ViewAll on OutboundWebhooks.",
        "operationId": "ListOutboundWebhooks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundWebhookDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "Create Webhook",
        "description": "Creates a webhook and answers its signing secret, the only time besides a rotation that it is returned. Event types come from the catalogue, or * alone for everything. The practice's first webhook sets it up in the Webhook Service through Account Hub. 400 with field errors (event types, name, an https URL), or when the practice is not linked to Account Hub; 409 while webhooks are not switched on in this environment, or when it already has as many webhooks as it may; 503 when the Webhook Service or Account Hub is unavailable.\n\nRequires: Create on OutboundWebhooks.",
        "operationId": "CreateOutboundWebhook",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOutboundWebhookRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundWebhookCreatedDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/webhooks/{webhookId}": {
      "get": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "Get Webhook",
        "description": "One of the practice's webhooks, with how its receiver has been answering. Never its secret. 409 while webhooks are not switched on in this environment.\n\nRequires: ViewAll on OutboundWebhooks.",
        "operationId": "GetOutboundWebhook",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundWebhookDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "Update Webhook",
        "description": "Replaces the webhook's name, URL, event types, payload mode and whether it is enabled; its secret is kept. Switching it off cancels its deliveries still waiting; switching it back on, or a new URL, clears its failure history. 400 with field errors. 409 while webhooks are not switched on in this environment.\n\nRequires: Update on OutboundWebhooks.",
        "operationId": "UpdateOutboundWebhook",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOutboundWebhookRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundWebhookDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "Delete Webhook",
        "description": "Removes the webhook with its secrets and delivery log. 409 while webhooks are not switched on in this environment.\n\nRequires: Delete on OutboundWebhooks.",
        "operationId": "DeleteOutboundWebhook",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/webhooks/{webhookId}/secret/rotate": {
      "post": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "Rotate Webhook Secret",
        "description": "Issues the webhook a new signing secret, answered once. The secret it replaces stays valid for a day, and deliveries are signed with both until then. 409 while webhooks are not switched on in this environment.\n\nRequires: Update on OutboundWebhooks.",
        "operationId": "RotateOutboundWebhookSecret",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundWebhookRotatedSecretDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/webhooks/{webhookId}/test": {
      "post": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "Send Webhook Test",
        "description": "Sends a webhook.test event to this webhook alone, whatever it subscribes to, and answers the delivery; read the delivery for the result. One attempt, never retried, and it never counts against the webhook's health. 400 while the webhook is switched off. 409 while webhooks are not switched on in this environment.\n\nRequires: Update on OutboundWebhooks.",
        "operationId": "SendOutboundWebhookTest",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundWebhookDeliveryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/webhooks/deliveries": {
      "get": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "List Webhook Deliveries",
        "description": "What was sent to the practice's webhooks, newest first: optionally for one webhook, in one status, of one event type, created from startDate (inclusive) to endDate (exclusive), UTC instants; offset, and limit (10 by default, at most 50). Empty for a practice that has never created a webhook. 409 while webhooks are not switched on in this environment.\n\nRequires: ViewAll on OutboundWebhooks.",
        "operationId": "ListOutboundWebhookDeliveries",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "startDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "x-order": 100
          },
          {
            "name": "endDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "x-order": 101
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/OutboundWebhookDeliveryStatus"
            },
            "x-order": 200
          },
          {
            "name": "eventType",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "webhookId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundWebhookDeliveryDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/webhooks/deliveries/{deliveryId}": {
      "get": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "Get Webhook Delivery",
        "description": "One delivery with the exact body it sends and every attempt made, oldest first. 409 while webhooks are not switched on in this environment.\n\nRequires: ViewAll on OutboundWebhooks.",
        "operationId": "GetOutboundWebhookDelivery",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundWebhookDeliveryDetailDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/webhooks/deliveries/{deliveryId}/retry": {
      "post": {
        "tags": [
          "Outbound Webhooks"
        ],
        "summary": "Retry Webhook Delivery",
        "description": "Sends a failed delivery once more, now. 409 unless the delivery failed, its webhook is enabled and it is not a test, and while webhooks are not switched on in this environment.\n\nRequires: Update on OutboundWebhooks.",
        "operationId": "RetryOutboundWebhookDelivery",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundWebhookDeliveryDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "503": {
            "description": "Service Unavailable"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "OutboundWebhooks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/notes/pinned-to-dashboard": {
      "get": {
        "tags": [
          "Pinned Notes"
        ],
        "summary": "Get Notes Pinned to Dashboard",
        "description": "Returns the client and task notes pinned to the dashboard (PinnedLevel 3), most recent first, capped at 100. Client notes need Clients view access and task notes need Tasks view access; a user restricted to their teams' or assigned clients only sees notes on those clients.\n\nOpen to any signed-in user of the tenant: The handler includes client and task notes only for a caller who can view clients and tasks",
        "operationId": "GetNotesPinnedToDashboard",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DashboardPinnedNoteDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The handler includes client and task notes only for a caller who can view clients and tasks"
      }
    },
    "/tenants/{tenant}/pipeline-onboarding-task-templates": {
      "get": {
        "tags": [
          "Pipeline - Intake Tasks"
        ],
        "summary": "List PipelineOnboardingTaskTemplates",
        "description": "Lists all PipelineOnboardingTaskTemplates for the given tenant.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "ListPipelineOnboardingTaskTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/PipelineOnboardingTaskTemplateSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "pipelineCode",
            "in": "query",
            "description": "Filter by pipeline code",
            "schema": {
              "type": "string",
              "example": "sales-pipeline"
            }
          },
          {
            "name": "isActive",
            "in": "query",
            "description": "Filter by active status (true = active only, false = inactive only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across template code, name, and description (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "qualify"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineOnboardingTaskTemplateDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Pipeline - Intake Tasks"
        ],
        "summary": "Create PipelineOnboardingTaskTemplate",
        "description": "Creates a new PipelineOnboardingTaskTemplate for the specified tenant.\n\nRequires: Create on Pipelines.",
        "operationId": "CreatePipelineOnboardingTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePipelineOnboardingTaskTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineOnboardingTaskTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/pipeline-onboarding-task-templates/{code}": {
      "get": {
        "tags": [
          "Pipeline - Intake Tasks"
        ],
        "summary": "Get PipelineOnboardingTaskTemplate",
        "description": "Gets a PipelineOnboardingTaskTemplate for the specified tenant.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "GetPipelineOnboardingTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineOnboardingTaskTemplateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Pipeline - Intake Tasks"
        ],
        "summary": "Update PipelineOnboardingTaskTemplate",
        "description": "Updates a PipelineOnboardingTaskTemplate for the specified tenant.\n\nRequires: Update on Pipelines.",
        "operationId": "UpdatePipelineOnboardingTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePipelineOnboardingTaskTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineOnboardingTaskTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Pipeline - Intake Tasks"
        ],
        "summary": "Delete PipelineOnboardingTaskTemplate",
        "description": "Deletes a PipelineOnboardingTaskTemplate for the specified tenant.\n\nRequires: Delete on Pipelines.",
        "operationId": "DeletePipelineOnboardingTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/pipeline-onboarding-task-templates/{code}/library-version": {
      "put": {
        "tags": [
          "Pipeline - Intake Tasks"
        ],
        "summary": "Revert PipelineOnboardingTaskTemplate to Library",
        "description": "Reverts the PipelineOnboardingTaskTemplate to the current library template version, overwriting any local edits. The PipelineOnboardingTaskTemplate's code is preserved so it remains addressable at the same URL. Returns 400 if the PipelineOnboardingTaskTemplate was not imported from the library, or 404 if the PipelineOnboardingTaskTemplate or its source library template no longer exists.\n\nRequires: Update on Pipelines.",
        "operationId": "RevertPipelineOnboardingTaskTemplateToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineOnboardingTaskTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/pipelines": {
      "get": {
        "tags": [
          "Pipelines"
        ],
        "summary": "List Pipelines",
        "description": "Lists all Pipelines for the given tenant.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "ListPipelines",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/PipelineSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "isArchived",
            "in": "query",
            "description": "Filter by archived status (true = archived only, false = active only)",
            "schema": {
              "type": "boolean",
              "example": "false"
            }
          },
          {
            "name": "hasStages",
            "in": "query",
            "description": "Filter to only pipelines that have stages defined (true = with stages only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "showKanbanBoard",
            "in": "query",
            "description": "Filter to only pipelines with kanban board enabled (true = kanban-enabled only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across pipeline code and name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "sales"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Pipelines"
        ],
        "summary": "Create Pipeline",
        "description": "Creates a new Pipeline for the specified tenant.\n\nRequires: Create on Pipelines.",
        "operationId": "CreatePipeline",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePipelineRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/pipelines/{code}": {
      "get": {
        "tags": [
          "Pipelines"
        ],
        "summary": "Get Pipeline",
        "description": "Gets a Pipeline for the specified tenant.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "GetPipeline",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Pipelines"
        ],
        "summary": "Update Pipeline",
        "description": "Updates a Pipeline for the specified tenant.\n\nRequires: Update on Pipelines.",
        "operationId": "UpdatePipeline",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePipelineRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Pipelines"
        ],
        "summary": "Delete Pipeline",
        "description": "Deletes a Pipeline for the specified tenant.\n\nRequires: Delete on Pipelines.",
        "operationId": "DeletePipeline",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/pipelines/library": {
      "get": {
        "tags": [
          "Pipelines"
        ],
        "summary": "List Library Pipelines",
        "description": "List all Pipelines available in the library as templates. Use optional 'search' query parameter to filter by Code, Name, or Description.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "ListLibraryPipelines",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PipelineDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/pipelines/library/{code}": {
      "get": {
        "tags": [
          "Pipelines"
        ],
        "summary": "Get Library Pipeline",
        "description": "Get details of a specific Pipeline template from the library\n\nRequires: ViewAll on Pipelines.",
        "operationId": "GetLibraryPipeline",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/pipelines/{code}/library-version": {
      "put": {
        "tags": [
          "Pipelines"
        ],
        "summary": "Revert Pipeline to Library",
        "description": "Reverts the Pipeline to the current library template version, overwriting any local edits. The Pipeline's code is preserved so it remains addressable at the same URL. Returns 400 if the Pipeline was not imported from the library, or 404 if the Pipeline or its source library template no longer exists.\n\nRequires: Update on Pipelines.",
        "operationId": "RevertPipelineToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PipelineDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/pipelines/library/import": {
      "post": {
        "tags": [
          "Pipelines"
        ],
        "summary": "Import Pipelines from Library",
        "description": "Imports one or more pipelines from the library, cascading their stages, intake task templates, recurring tasks and referenced workflows into the tenant.\n\nRequires: Create on Pipelines.",
        "operationId": "ImportPipelinesFromLibrary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportPipelinesFromLibraryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PipelineDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/pipelines/{code}/value-totals": {
      "get": {
        "tags": [
          "Pipelines"
        ],
        "summary": "Get Pipeline Value Totals",
        "description": "Returns the full and likelihood-weighted deal value per stage, over every card on the pipeline that matches the filters. The filters are the board's (client manager, partner, search, minimum likelihood), so the totals match the board column by column. Stages with no matching cards are omitted.\n\nRequires: ViewAll on Pipelines.",
        "operationId": "GetPipelineValueTotals",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "partnerCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 211
          },
          {
            "name": "clientManagerCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "minLikelihood",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PipelineStageValueTotalDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice": {
      "get": {
        "tags": [
          "Practice"
        ],
        "summary": "Get Practice Details",
        "description": "Returns the practice details for the specified tenant\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetPracticeDetails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeDetailsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Practice"
        ],
        "summary": "Update Practice Details",
        "description": "Updates the practice details for the specified tenant\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdatePracticeDetails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePracticeDetailsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeDetailsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/practice-note": {
      "get": {
        "tags": [
          "Practice Note"
        ],
        "summary": "Get Practice Note",
        "description": "Gets the practice's shared note. Comes back empty when nothing has been written yet.\n\nOpen to any signed-in user of the tenant: The shared practice note is readable and writable by every user in the practice",
        "operationId": "GetPracticeNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PracticeNoteDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The shared practice note is readable and writable by every user in the practice"
      },
      "put": {
        "tags": [
          "Practice Note"
        ],
        "summary": "Update Practice Note",
        "description": "Saves the practice's shared note. The save is rejected when somebody else has saved since the version being edited, in which case their note comes back untouched with saved=false. Send an empty string to clear it.\n\nOpen to any signed-in user of the tenant: The shared practice note is readable and writable by every user in the practice",
        "operationId": "UpdatePracticeNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePracticeNoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavePracticeNoteResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The shared practice note is readable and writable by every user in the practice"
      }
    },
    "/tenants/{tenant}/professionalclearance/items": {
      "get": {
        "tags": [
          "Professional Clearance"
        ],
        "summary": "List ProfessionalClearanceRequestItems",
        "description": "Lists all ProfessionalClearanceRequestItems for the given tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "ListProfessionalClearanceRequestItems",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ProfessionalClearanceRequestItemSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProfessionalClearanceRequestItemDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Professional Clearance"
        ],
        "summary": "Create ProfessionalClearanceRequestItem",
        "description": "Creates a new ProfessionalClearanceRequestItem for the specified tenant.\n\nRequires: Create on PracticeDetails.",
        "operationId": "CreateProfessionalClearanceRequestItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateProfessionalClearanceRequestItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProfessionalClearanceRequestItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Create"
          }
        ]
      },
      "patch": {
        "tags": [
          "Professional Clearance"
        ],
        "summary": "Reorder Clearance Items",
        "description": "Saves the complete new order of the tenant's professional clearance request items in a\nsingle change. Each code's sort order becomes its 0-based position in the list, so the whole\nlist is renumbered and any gaps left by deleted items are removed. Rejected as a whole when\nthe list is empty, contains duplicates, or names an item that does not exist.\n\nRequires: Update on PracticeDetails.",
        "operationId": "ReorderProfessionalClearanceRequestItems",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReorderProfessionalClearanceRequestItemsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/professionalclearance/items/{code}": {
      "get": {
        "tags": [
          "Professional Clearance"
        ],
        "summary": "Get ProfessionalClearanceRequestItem",
        "description": "Gets a ProfessionalClearanceRequestItem for the specified tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetProfessionalClearanceRequestItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProfessionalClearanceRequestItemDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Professional Clearance"
        ],
        "summary": "Update ProfessionalClearanceRequestItem",
        "description": "Updates a ProfessionalClearanceRequestItem for the specified tenant.\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateProfessionalClearanceRequestItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateProfessionalClearanceRequestItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProfessionalClearanceRequestItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Professional Clearance"
        ],
        "summary": "Delete ProfessionalClearanceRequestItem",
        "description": "Deletes a ProfessionalClearanceRequestItem for the specified tenant.\n\nRequires: Delete on PracticeDetails.",
        "operationId": "DeleteProfessionalClearanceRequestItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/professionalclearance/settings": {
      "get": {
        "tags": [
          "Professional Clearance"
        ],
        "summary": "Get Settings",
        "description": "Returns the professional clearance letter settings for the specified tenant\n\nOpen to any signed-in user of the tenant: Practice-wide reference settings, readable by every user in the practice",
        "operationId": "GetProfessionalClearanceLetterSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProfessionalClearanceLetterSettingsDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Practice-wide reference settings, readable by every user in the practice"
      },
      "put": {
        "tags": [
          "Professional Clearance"
        ],
        "summary": "Update Settings",
        "description": "Updates the professional clearance letter settings for the specified tenant\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateProfessionalClearanceLetterSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateProfessionalClearanceLetterSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProfessionalClearanceLetterSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/pcl/items": {
      "get": {
        "tags": [
          "Professional Clearance"
        ],
        "summary": "Get Client Clearance Items",
        "description": "Returns all professional clearance request items for the client based on their non-inactive billable services, including global items\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetClientPclItems",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProfessionalClearanceRequestItemDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/service-delivery": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Service Delivery Report",
        "description": "Service Delivery Turnaround: headline KPIs (avg/median turnaround, on-time rate, statutory compliance, currently overdue) plus a breakdown table grouped by service, client, assignee, or completion month. The cohort is tasks completed in the requested window; Skipped tasks are excluded unless includeSkipped=true.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetServiceDeliveryReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the completion window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Service (default), Client, AssignedUser, or Month",
            "schema": {
              "enum": [
                "Service",
                "Client",
                "AssignedUser",
                "Month"
              ],
              "type": "string"
            }
          },
          {
            "name": "includeSkipped",
            "in": "query",
            "description": "Count Skipped tasks as delivered alongside Completed ones (default false)",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by assigned user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by assigned team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceDeliveryReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/service-delivery/steps": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Service Delivery Step Bottlenecks",
        "description": "Step-level drill-down for one billable service: average elapsed time per workflow step (from the previous step's completion, so idle time counts), chase counts, and the client-wait vs internal split - is it us or the client.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetServiceDeliveryStepBottlenecks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "serviceCode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the completion window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Service (default), Client, AssignedUser, or Month",
            "schema": {
              "enum": [
                "Service",
                "Client",
                "AssignedUser",
                "Month"
              ],
              "type": "string"
            }
          },
          {
            "name": "includeSkipped",
            "in": "query",
            "description": "Count Skipped tasks as delivered alongside Completed ones (default false)",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by assigned user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by assigned team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceDeliveryStepsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/service-delivery/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Service Delivery Report",
        "description": "The breakdown table as a CSV download - same filters and grouping as the report endpoint.\n\nRequires: Export on Reports.",
        "operationId": "GetServiceDeliveryReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the completion window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Service (default), Client, AssignedUser, or Month",
            "schema": {
              "enum": [
                "Service",
                "Client",
                "AssignedUser",
                "Month"
              ],
              "type": "string"
            }
          },
          {
            "name": "includeSkipped",
            "in": "query",
            "description": "Count Skipped tasks as delivered alongside Completed ones (default false)",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by assigned user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by assigned team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/deadline-compliance": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Deadline Compliance Report",
        "description": "Which deadlines did we miss, and which are we about to? The cohort is every non-Skipped task whose chosen deadline (due date, or statutory due date via deadlineType) fell in the window - met / completed-late / missed-still-open / pending - grouped by service, client, assignee, or deadline month, plus the forward-looking days-remaining buckets over currently-open work.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetDeadlineComplianceReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the deadline window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Deadline window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Deadline window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Service (default), Client, AssignedUser, or Month",
            "schema": {
              "enum": [
                "Service",
                "Client",
                "AssignedUser",
                "Month"
              ],
              "type": "string"
            }
          },
          {
            "name": "deadlineType",
            "in": "query",
            "description": "Deadline to measure against: DueDate (default) or StatutoryDueDate (restricts to tasks that have one)",
            "schema": {
              "enum": [
                "DueDate",
                "StatutoryDueDate"
              ],
              "type": "string"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by assigned user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by assigned team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeadlineComplianceReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/deadline-compliance/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Deadline Compliance Report",
        "description": "The breakdown table as a CSV download - same filters and grouping as the report endpoint.\n\nRequires: Export on Reports.",
        "operationId": "GetDeadlineComplianceReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the deadline window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Deadline window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Deadline window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Service (default), Client, AssignedUser, or Month",
            "schema": {
              "enum": [
                "Service",
                "Client",
                "AssignedUser",
                "Month"
              ],
              "type": "string"
            }
          },
          {
            "name": "deadlineType",
            "in": "query",
            "description": "Deadline to measure against: DueDate (default) or StatutoryDueDate (restricts to tasks that have one)",
            "schema": {
              "enum": [
                "DueDate",
                "StatutoryDueDate"
              ],
              "type": "string"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by assigned user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by assigned team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/client-responsiveness": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Client Responsiveness Report",
        "description": "Is it us or the client: response times and chase pressure over client-facing workflow steps (confirmations, document requests, data forms, approvals) completed in the window, grouped by client, service, or step type, plus the currently-outstanding snapshot.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetClientResponsivenessReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the step-completion window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Step-completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Step-completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Client (default), Service, or StepType",
            "schema": {
              "enum": [
                "Client",
                "Service",
                "StepType"
              ],
              "type": "string"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientResponsivenessReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/client-responsiveness/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Client Responsiveness Report",
        "description": "The breakdown table as a CSV download - same filters and grouping as the report endpoint.\n\nRequires: Export on Reports.",
        "operationId": "GetClientResponsivenessReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the step-completion window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Step-completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Step-completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Client (default), Service, or StepType",
            "schema": {
              "enum": [
                "Client",
                "Service",
                "StepType"
              ],
              "type": "string"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/team-workload": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Team Workload Report",
        "description": "Who's overloaded and who completes what: the open-workload snapshot per assignee (open, overdue, blocked) plus completion throughput over the window (completions, average turnaround, on-time rate). Group by user (completions attributed to who completed the task) or team.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetTeamWorkloadReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the completion window (default Last30Days). If CustomDateRange, startDate and endDate are required. Open-workload counts are always a now snapshot.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: User (default) or Team",
            "schema": {
              "enum": [
                "User",
                "Team"
              ],
              "type": "string"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamWorkloadReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/team-workload/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Team Workload Report",
        "description": "The breakdown table as a CSV download - same filters and grouping as the report endpoint.\n\nRequires: Export on Reports.",
        "operationId": "GetTeamWorkloadReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the completion window (default Last30Days). If CustomDateRange, startDate and endDate are required. Open-workload counts are always a now snapshot.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: User (default) or Team",
            "schema": {
              "enum": [
                "User",
                "Team"
              ],
              "type": "string"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/wip-ageing": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get WIP Ageing Report",
        "description": "What's sitting untouched: a point-in-time snapshot of open tasks whose planned start has arrived, grouped by age bucket, status, service, client, assignee, or current workflow step. No date range - age is measured from planned start to today.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetWipAgeingReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: AgeBucket (default), Status, Service, Client, AssignedUser, or CurrentStep",
            "schema": {
              "enum": [
                "AgeBucket",
                "Status",
                "Service",
                "Client",
                "AssignedUser",
                "CurrentStep"
              ],
              "type": "string"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by assigned user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by assigned team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WipAgeingReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/wip-ageing/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export WIP Ageing Report",
        "description": "The breakdown table as a CSV download - same filters and grouping as the report endpoint.\n\nRequires: Export on Reports.",
        "operationId": "GetWipAgeingReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: AgeBucket (default), Status, Service, Client, AssignedUser, or CurrentStep",
            "schema": {
              "enum": [
                "AgeBucket",
                "Status",
                "Service",
                "Client",
                "AssignedUser",
                "CurrentStep"
              ],
              "type": "string"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\" ]"
            }
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by assigned user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by assigned team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\" ]"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/workflow-steps": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Workflow Step Analysis Report",
        "description": "For one workflow template, where does the time go? Per-step duration distributions (median/avg/best/worst/p90, active vs elapsed, skips, chases, client-wait vs internal) across every occurrence (task) spawned from the workflow and completed in the window, divided into the workflow's groups. The occurrence list is served separately (paged) by the occurrences endpoint.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetWorkflowStepAnalysisReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "workflowCode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the task-completion window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Task-completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Task-completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepAnalysisReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/workflow-steps/occurrences": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "List Workflow Step Analysis Occurrences",
        "description": "One page of the Workflow Step Analysis occurrence list - one row per task spawned from the workflow and completed in the window, slowest first, with the client-wait vs internal split. Standard offset/limit paging.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetWorkflowStepAnalysisOccurrences",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "workflowCode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the task-completion window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Task-completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Task-completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowOccurrenceDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/service-time": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Service Time Report",
        "description": "Estimated vs actual time per service: total minutes logged in the window attributed to services via each entry's linked task, compared against the summed estimates of those tasks. Drill down with serviceCode (rows per client), serviceCode + clientCode (rows per task) and taskCode (rows per workflow step); below the service level a catch-all row makes the rows add up to the row drilled from, and the summary covers the drilled scope. groupBy=TeamMember gives one row per person instead (narrow it with serviceCode): time by who logged it, estimates by the step's (or task's) assignee. Requires time tracking to be in use.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetServiceTimeReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the time entry window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Entry window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Entry window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Drill into one service - rows group by client instead of by service. With groupBy=TeamMember, narrows the team member view to the service",
            "schema": {
              "type": "string",
              "example": "annual-accounts"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "With serviceCode, drill into one client - rows group by task",
            "schema": {
              "type": "string",
              "example": "CLI-0001"
            }
          },
          {
            "name": "taskCode",
            "in": "query",
            "description": "Drill into one task - rows group by workflow step. Not combined with serviceCode or clientCode",
            "schema": {
              "type": "string",
              "example": "TSK-0001"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Service (default, drillable) or TeamMember (optionally filtered by serviceCode; no clientCode or taskCode)",
            "schema": {
              "enum": [
                "Service",
                "TeamMember",
                "Stage"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceTimeReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/service-time/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Service Time Report",
        "description": "The breakdown table as a CSV download - same filters as the report endpoint, so it covers whichever level the parameters select.\n\nRequires: Export on Reports.",
        "operationId": "GetServiceTimeReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the time entry window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Entry window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Entry window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Drill into one service - rows group by client instead of by service. With groupBy=TeamMember, narrows the team member view to the service",
            "schema": {
              "type": "string",
              "example": "annual-accounts"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "With serviceCode, drill into one client - rows group by task",
            "schema": {
              "type": "string",
              "example": "CLI-0001"
            }
          },
          {
            "name": "taskCode",
            "in": "query",
            "description": "Drill into one task - rows group by workflow step. Not combined with serviceCode or clientCode",
            "schema": {
              "type": "string",
              "example": "TSK-0001"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Service (default, drillable) or TeamMember (optionally filtered by serviceCode; no clientCode or taskCode)",
            "schema": {
              "enum": [
                "Service",
                "TeamMember",
                "Stage"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/team-time": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Team Time Report",
        "description": "Hours logged per team member over the window against the hours they were expected to log, so under-logging and over-logging both stand out without checking person by person. Members who logged nothing still get a row. Expectations come from each member's expected week (or the practice standard), pro-rated across working days with holidays and the member's time off taken out, and capped at today when the window runs past it. Each team gets a total over its members. Short windows also carry a per-day breakdown, and every window carries each member's split by task category. Pass teamCode to narrow to one team, or categoryCode to narrow every figure to one task category (which drops the expectation, since a working pattern covers all work rather than one category's). Requires time tracking to be in use.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetTeamTimeReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the time entry window (default ThisWeek). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Entry window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Entry window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "teamCode",
            "in": "query",
            "description": "Limit the rows to the members of one team",
            "schema": {
              "type": "string",
              "example": "TEAM-001"
            }
          },
          {
            "name": "categoryCode",
            "in": "query",
            "description": "Limit the figures to time logged against tasks in one task category",
            "schema": {
              "type": "string",
              "example": "CAT-001"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamTimeReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/team-time/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Team Time Report",
        "description": "The per-member table as a CSV download, in hours - same filters as the report endpoint.\n\nRequires: Export on Reports.",
        "operationId": "GetTeamTimeReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the time entry window (default ThisWeek). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Entry window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Entry window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "teamCode",
            "in": "query",
            "description": "Limit the rows to the members of one team",
            "schema": {
              "type": "string",
              "example": "TEAM-001"
            }
          },
          {
            "name": "categoryCode",
            "in": "query",
            "description": "Limit the figures to time logged against tasks in one task category",
            "schema": {
              "type": "string",
              "example": "CAT-001"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/team-time/categories/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Team Time Category Breakdown",
        "description": "Each team member's hours split by task category as a CSV download - one row per member, one column per category anyone logged against, plus an uncategorised column. Same filters as the report endpoint.\n\nRequires: Export on Reports.",
        "operationId": "GetTeamTimeCategoryReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the time entry window (default ThisWeek). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Entry window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Entry window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "teamCode",
            "in": "query",
            "description": "Limit the rows to the members of one team",
            "schema": {
              "type": "string",
              "example": "TEAM-001"
            }
          },
          {
            "name": "categoryCode",
            "in": "query",
            "description": "Limit the figures to time logged against tasks in one task category",
            "schema": {
              "type": "string",
              "example": "CAT-001"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/capacity": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Capacity Report",
        "description": "Planned hours against available hours per team member, week by week or month by month from the current period forward, so over- and under-loaded people stand out. Planned hours are the remaining estimate (estimate less time logged) of open work: each workflow step on its planned date when the task's estimate comes from its steps, otherwise the whole task spread over its assignee's working days from start to due. Work dated before today is planned onto today. Available hours come from each member's working pattern with bank and practice holidays and their own time off taken out, from today in the current period, and a task is never spread onto someone's day off. Team-held and unassigned work get rows of their own, and each cell counts the work that has no estimate. Recurring work not yet created as a task counts as it will be created. Pass teamCode to narrow to one team.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetCapacityReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "period",
            "in": "query",
            "description": "Column size: Week (Monday to Sunday) or Month (default Week)",
            "schema": {
              "enum": [
                "Week",
                "Month"
              ],
              "type": "string"
            }
          },
          {
            "name": "periods",
            "in": "query",
            "description": "How many periods to show, starting with the current one (default 6 weeks or 3 months; at most 26 weeks or 12 months)",
            "schema": {
              "type": "integer",
              "example": "6"
            }
          },
          {
            "name": "teamCode",
            "in": "query",
            "description": "Limit the rows to one team's members and the work assigned to that team",
            "schema": {
              "type": "string",
              "example": "TEAM-001"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapacityReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/capacity/items": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "List Capacity Report Items",
        "description": "The open steps and tasks behind one Capacity report cell - one row (a member, a team's held work, or the unassigned work) over one period - placed the same way as the report, so their planned minutes add up to the cell. Each item carries the task code, and the group and step numbers for a step, so it can be reassigned. Recurring work not yet created as a task carries its projected task code and isProjected, and is materialised before it is changed.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetCapacityReportItems",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "assigneeKind",
            "in": "query",
            "description": "The row's kind: User, Team or Unassigned",
            "schema": {
              "enum": [
                "Service",
                "Client",
                "User",
                "Team",
                "StepType",
                "AgeBucket",
                "Status",
                "CurrentStep",
                "None",
                "Month",
                "Unassigned",
                "Task",
                "WorkflowStep",
                "Stage"
              ],
              "type": "string"
            }
          },
          {
            "name": "assigneeCode",
            "in": "query",
            "description": "The TenantUser or Team code of the row (not used for Unassigned)",
            "schema": {
              "type": "string",
              "example": "USR-001"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "First day of the cell's period (inclusive)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Last day of the cell's period (inclusive)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CapacityItemDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/cost-profit": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Cost & Profit Report",
        "description": "What tracked time cost the practice over the window, what the billable portion is worth, and the profit between the two, grouped by team member, client or client service. Grouped by client service it is per-job recovery: each job's price and fee budget for the periods starting in the window sit beside its value and what was billed (those two columns for Fee Budgets holders only). Cost counts all time (billable or not) at the stamped cost rates; billable value counts billable time at the stamped charge-out rates, whether billed yet or not. Requires time tracking to be in use and the Cost Rates permission.\n\nRequires: ViewAll on Reports and ViewAll on CostRates.",
        "operationId": "GetCostProfitReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the time entry window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Entry window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Entry window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: User (default) or Client",
            "schema": {
              "enum": [
                "User",
                "Client",
                "ClientService"
              ],
              "type": "string"
            }
          },
          {
            "name": "teamCode",
            "in": "query",
            "description": "Limit the entries to those logged by the members of one team",
            "schema": {
              "type": "string",
              "example": "TEAM-001"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CostProfitReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          },
          {
            "entity": "CostRates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/cost-profit/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Cost & Profit Report",
        "description": "The breakdown table as a CSV download - same filters and grouping as the report endpoint, hours to one decimal place and money to two.\n\nRequires: Export on Reports and ViewAll on CostRates.",
        "operationId": "GetCostProfitReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the time entry window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Entry window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Entry window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: User (default) or Client",
            "schema": {
              "enum": [
                "User",
                "Client",
                "ClientService"
              ],
              "type": "string"
            }
          },
          {
            "name": "teamCode",
            "in": "query",
            "description": "Limit the entries to those logged by the members of one team",
            "schema": {
              "type": "string",
              "example": "TEAM-001"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          },
          {
            "entity": "CostRates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/write-offs": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Write-off Analysis Report",
        "description": "Time written off (or on) against fees over the window, grouped by reason, team member or client. The cohort is every time allocation recorded in the window, dated by when the disposal was recorded. Recovery is measured against Sodium's billing lines, not the invoice the accounting platform issued. Requires time tracking to be in use.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetWriteOffReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for when the write-offs were recorded (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Reason (default), User or Client",
            "schema": {
              "enum": [
                "Reason",
                "User",
                "Client"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteOffReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/write-offs/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Write-off Analysis Report",
        "description": "The breakdown table as a CSV download - same filters and grouping as the report endpoint, money to two decimal places.\n\nRequires: Export on Reports.",
        "operationId": "GetWriteOffReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for when the write-offs were recorded (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Reason (default), User or Client",
            "schema": {
              "enum": [
                "Reason",
                "User",
                "Client"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/fee-overrides": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get Fee Overrides Report",
        "description": "Every fee that differs from its default today, one row per fee: client service and proposal prices, package prices, setup and catch-up fees, billing schedule lines whose amount a user changed, and one-off charges. Each row carries the default (from today's price list, with the client's pricing factors), the overridden fee, the difference and the difference per year, and who made the override and when, read from the row's history. Ended services, rejected proposals and skipped schedule lines are left out. The date range and user filters apply to who and when; with no date range every standing override is listed. The summary covers every row the filters keep.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetFeeOverrideReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for when the overrides were made. Omit for every override standing today. If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userCode",
            "in": "query",
            "description": "Only overrides made by this team member (their user code)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "feeType",
            "in": "query",
            "description": "Only this kind of fee: Price, PackagePrice, SetupFee, CatchUpFee, ScheduleLine or OneOffCharge",
            "schema": {
              "enum": [
                "Price",
                "PackagePrice",
                "SetupFee",
                "CatchUpFee",
                "ScheduleLine",
                "OneOffCharge"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeOverrideReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/fee-overrides/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Fee Overrides Report",
        "description": "The rows as a CSV download - same filters as the report endpoint, every row, money to two decimal places.\n\nRequires: Export on Reports.",
        "operationId": "GetFeeOverrideReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for when the overrides were made. Omit for every override standing today. If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userCode",
            "in": "query",
            "description": "Only overrides made by this team member (their user code)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "feeType",
            "in": "query",
            "description": "Only this kind of fee: Price, PackagePrice, SetupFee, CatchUpFee, ScheduleLine or OneOffCharge",
            "schema": {
              "enum": [
                "Price",
                "PackagePrice",
                "SetupFee",
                "CatchUpFee",
                "ScheduleLine",
                "OneOffCharge"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/wip-value": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get WIP Value Report",
        "description": "A point-in-time snapshot of billable time not yet billed or written off, valued at the stamped charge-out rates and aged from the day it was worked, grouped by client, service or team member. Each row also carries the all-time billable value, what was settled and billed, money billed to the job on lines with no time behind them, and the recovery rate. Distinct from WIP / Ageing, which is about open tasks. Time billed before the allocation model existed reads as fully recovered. Requires time tracking to be in use.\n\nRequires: ViewAll on Reports.",
        "operationId": "GetTimeWipReport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Client (default), Service or User",
            "schema": {
              "enum": [
                "Client",
                "Service",
                "User"
              ],
              "type": "string"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Limit to one client's time",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeWipReportDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/wip-value/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export WIP Value Report",
        "description": "The breakdown table as a CSV download - same grouping and client filter as the report endpoint, money to two decimal places.\n\nRequires: Export on Reports.",
        "operationId": "GetTimeWipReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupBy",
            "in": "query",
            "description": "Breakdown dimension: Client (default), Service or User",
            "schema": {
              "enum": [
                "Client",
                "Service",
                "User"
              ],
              "type": "string"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Limit to one client's time",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/reports/workflow-steps/csv": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Export Workflow Step Analysis Report",
        "description": "The per-step table as a CSV download - same filters as the report endpoint.\n\nRequires: Export on Reports.",
        "operationId": "GetWorkflowStepAnalysisReportCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "workflowCode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the task-completion window (default Last30Days). If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Task-completion window start (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Task-completion window end (inclusive). Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/requests/summary": {
      "get": {
        "tags": [
          "Requests"
        ],
        "summary": "Get Request Summary",
        "description": "Returns the outstanding count for each kind of item on the Requests page in one call:\nsteps ready to send, pending scheduled sends, forms awaiting a response, document\napprovals pending, document requests open and submitted, and open confirmations.\n\nReady to Send is scoped to the calling user, matching that tab's own default.\nA count the caller's role cannot read is null rather than zero.\n\nOpen to any signed-in user of the tenant: The use case checks each area it reports (tasks, data forms, documents, document requests, scheduled sends)",
        "operationId": "GetRequestSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestSummaryDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The use case checks each area it reports (tasks, data forms, documents, document requests, scheduled sends)"
      }
    },
    "/tenants/{tenant}/revenue-ranges": {
      "get": {
        "tags": [
          "Revenue Ranges"
        ],
        "summary": "List RevenueRanges",
        "description": "Lists all RevenueRanges for the given tenant.\n\nOpen to any signed-in user of the tenant: Practice-wide reference list, readable by every user in the practice",
        "operationId": "ListRevenueRanges",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/RevenueRangeSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RevenueRangeDtoPagedResult"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Practice-wide reference list, readable by every user in the practice"
      },
      "post": {
        "tags": [
          "Revenue Ranges"
        ],
        "summary": "Create RevenueRange",
        "description": "Creates a new RevenueRange for the specified tenant.\n\nRequires: Create on PracticeDetails.",
        "operationId": "CreateRevenueRange",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRevenueRangeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RevenueRangeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/revenue-ranges/{code}": {
      "get": {
        "tags": [
          "Revenue Ranges"
        ],
        "summary": "Get RevenueRange",
        "description": "Gets a RevenueRange for the specified tenant.\n\nOpen to any signed-in user of the tenant: Practice-wide reference list, readable by every user in the practice",
        "operationId": "GetRevenueRange",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RevenueRangeDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Practice-wide reference list, readable by every user in the practice"
      },
      "put": {
        "tags": [
          "Revenue Ranges"
        ],
        "summary": "Update RevenueRange",
        "description": "Updates a RevenueRange for the specified tenant.\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateRevenueRange",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRevenueRangeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RevenueRangeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Revenue Ranges"
        ],
        "summary": "Delete RevenueRange",
        "description": "Deletes a RevenueRange for the specified tenant.\n\nRequires: Delete on PracticeDetails.",
        "operationId": "DeleteRevenueRange",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/roles": {
      "get": {
        "tags": [
          "Roles"
        ],
        "summary": "List Roles",
        "description": "Lists all Roles for the given tenant.\n\nRequires: ViewAll on Roles.",
        "operationId": "ListRoles",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/RoleSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoleDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Roles",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Roles"
        ],
        "summary": "Create Role",
        "description": "Creates a custom role. Requested permissions are capped at the capabilities the requesting user holds on each entity.\n\nRequires: Create on Roles.",
        "operationId": "CreateRole",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRoleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoleDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Roles",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/roles/{code}": {
      "get": {
        "tags": [
          "Roles"
        ],
        "summary": "Get Role",
        "description": "Gets a Role for the specified tenant.\n\nRequires: ViewAll on Roles.",
        "operationId": "GetRole",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoleDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Roles",
            "permission": "ViewAll"
          }
        ]
      },
      "delete": {
        "tags": [
          "Roles"
        ],
        "summary": "Delete Role",
        "description": "Deletes a Role for the specified tenant.\n\nRequires: Delete on Roles.",
        "operationId": "DeleteRole",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Roles",
            "permission": "Delete"
          }
        ]
      },
      "put": {
        "tags": [
          "Roles"
        ],
        "summary": "Update Role",
        "description": "Replaces a custom role's name, description and permission set. Requested permissions are capped at the capabilities the requesting user holds on each entity.\n\nRequires: Update on Roles.",
        "operationId": "UpdateRole",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRoleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoleDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Roles",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/roles/system": {
      "get": {
        "tags": [
          "Roles"
        ],
        "summary": "List System Role Permissions",
        "description": "Lists the built-in system roles and the capabilities each grants, intersected with the tenant's package.\n\nRequires: ViewAll on Users.",
        "operationId": "ListSystemRolePermissions",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SystemRolePermissionsDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/sales-pipeline-settings": {
      "get": {
        "tags": [
          "Sales Pipeline - Settings"
        ],
        "summary": "Get sales pipeline settings",
        "description": "Returns the sales pipeline settings for the specified tenant\n\nRequires: ViewAll on Pipelines.",
        "operationId": "GetSalesPipeline-Settings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesPipelineSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Sales Pipeline - Settings"
        ],
        "summary": "Update sales pipeline settings",
        "description": "Updates the sales pipeline settings (enable/disable the feature) for the specified tenant\n\nRequires: Update on Pipelines.",
        "operationId": "UpdateSalesPipeline-Settings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSalesPipelineSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesPipelineSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Pipelines",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/scheduled-sends": {
      "get": {
        "tags": [
          "Scheduled Sends"
        ],
        "summary": "List Scheduled Sends",
        "description": "Returns a paged list of scheduled sends, scoped to the send types the caller has permission to manage. Defaults to pending rows (Scheduled and Failed) when no status filter is given. Use limit=0 for a count-only query (the Scheduled tab badge).\n\nOpen to any signed-in user of the tenant: Each use case checks the permission of the row's send type (ScheduledSendPermissions)",
        "operationId": "ListScheduledSends",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ScheduledSendSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by one or more statuses. Defaults to Scheduled and Failed when omitted.",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "Scheduled",
                  "Dispatching",
                  "Sent",
                  "Cancelled",
                  "Failed"
                ],
                "type": "string"
              },
              "example": "Scheduled"
            }
          },
          {
            "name": "sendType",
            "in": "query",
            "description": "Filter by one or more kinds of send",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "MailboxEmail",
                  "MailboxSend",
                  "MailboxReply",
                  "WorkflowStep",
                  "DocumentRequestOpen",
                  "DataFormSend",
                  "DataFormBulkSend",
                  "DocumentApproval",
                  "EmailBroadcast",
                  "MailboxForward",
                  "Proposal",
                  "TextBroadcast"
                ],
                "type": "string"
              },
              "example": "WorkflowStep"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by the related client's code",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "createdByUserCode",
            "in": "query",
            "description": "Filter by the user who scheduled the send",
            "schema": {
              "type": "string",
              "example": "jane-smith"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across subject and client name",
            "schema": {
              "type": "string",
              "example": "VAT return"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Each use case checks the permission of the row's send type (ScheduledSendPermissions)"
      }
    },
    "/tenants/{tenant}/scheduled-sends/{code}": {
      "get": {
        "tags": [
          "Scheduled Sends"
        ],
        "summary": "Get Scheduled Send",
        "description": "Returns a scheduled send including its stored payload, used to prefill the edit dialogs. Raw uploaded attachments are represented by blob metadata rather than content.\n\nOpen to any signed-in user of the tenant: Each use case checks the permission of the row's send type (ScheduledSendPermissions)",
        "operationId": "GetScheduledSend",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDetailDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Each use case checks the permission of the row's send type (ScheduledSendPermissions)"
      },
      "put": {
        "tags": [
          "Scheduled Sends"
        ],
        "summary": "Update Scheduled Send",
        "description": "Reschedules a pending scheduled send and optionally replaces its editable payload content. Routing references (task/step, document request, form, broadcast) cannot be changed. Only Scheduled and Failed rows can be updated.\n\nOpen to any signed-in user of the tenant: Each use case checks the permission of the row's send type (ScheduledSendPermissions)",
        "operationId": "UpdateScheduledSend",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateScheduledSendRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Each use case checks the permission of the row's send type (ScheduledSendPermissions)"
      }
    },
    "/tenants/{tenant}/scheduled-sends/{code}/send-now": {
      "post": {
        "tags": [
          "Scheduled Sends"
        ],
        "summary": "Send Scheduled Send Now",
        "description": "Dispatches a pending scheduled send immediately instead of waiting for its scheduled time. Also the retry action for Failed rows.\n\nOpen to any signed-in user of the tenant: Each use case checks the permission of the row's send type (ScheduledSendPermissions)",
        "operationId": "SendScheduledSendNow",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Each use case checks the permission of the row's send type (ScheduledSendPermissions)"
      }
    },
    "/tenants/{tenant}/scheduled-sends/{code}/cancel": {
      "post": {
        "tags": [
          "Scheduled Sends"
        ],
        "summary": "Cancel Scheduled Send",
        "description": "Cancels a pending scheduled send. A held draft document request stays Draft; a scheduled broadcast returns to Draft and becomes editable again.\n\nOpen to any signed-in user of the tenant: Each use case checks the permission of the row's send type (ScheduledSendPermissions)",
        "operationId": "CancelScheduledSend",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Each use case checks the permission of the row's send type (ScheduledSendPermissions)"
      }
    },
    "/tenants/{tenant}/security-settings": {
      "get": {
        "tags": [
          "Security Settings"
        ],
        "summary": "Get security settings",
        "description": "Returns the security settings (MFA requirement, API key access) for the specified tenant\n\nRequires: ViewAll on Settings.",
        "operationId": "GetSecuritySettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SecuritySettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Settings",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Security Settings"
        ],
        "summary": "Update security settings",
        "description": "Updates the security settings for the specified tenant. Both settings take effect on the next request. Changing the MFA requirement re-syncs every active user's MFA flag with the identity provider, so they are challenged (or no longer challenged) at their next login.\n\nRequires: Update on Settings.",
        "operationId": "UpdateSecuritySettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSecuritySettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SecuritySettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Settings",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/service-categories": {
      "get": {
        "tags": [
          "Service - Categories"
        ],
        "summary": "List ServiceCategories",
        "description": "Lists all ServiceCategories for the given tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "ListServiceCategories",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ServiceCategorySortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCategoryDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Service - Categories"
        ],
        "summary": "Create ServiceCategory",
        "description": "Creates a new ServiceCategory for the specified tenant.\n\nRequires: Create on PracticeDetails.",
        "operationId": "CreateServiceCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateServiceCategoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCategoryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/service-categories/{code}": {
      "get": {
        "tags": [
          "Service - Categories"
        ],
        "summary": "Get ServiceCategory",
        "description": "Gets a ServiceCategory for the specified tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetServiceCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCategoryDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Service - Categories"
        ],
        "summary": "Update ServiceCategory",
        "description": "Updates a ServiceCategory for the specified tenant.\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateServiceCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateServiceCategoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCategoryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Service - Categories"
        ],
        "summary": "Delete ServiceCategory",
        "description": "Deletes a ServiceCategory for the specified tenant.\n\nRequires: Delete on PracticeDetails.",
        "operationId": "DeleteServiceCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/onboarding-task-templates": {
      "get": {
        "tags": [
          "Service - Onboarding Tasks"
        ],
        "summary": "List OnboardingTaskTemplates",
        "description": "Lists all OnboardingTaskTemplates for the given tenant.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListOnboardingTaskTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/OnboardingTaskTemplateSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Filter by billable service code",
            "schema": {
              "type": "string",
              "example": "VAT-001"
            }
          },
          {
            "name": "isActive",
            "in": "query",
            "description": "Filter by active status (true = active only, false = inactive only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across template code, name, and description (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "vat"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingTaskTemplateDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Service - Onboarding Tasks"
        ],
        "summary": "Create OnboardingTaskTemplate",
        "description": "Creates a new OnboardingTaskTemplate for the specified tenant.\n\nRequires: Create on Tasks.",
        "operationId": "CreateOnboardingTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOnboardingTaskTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingTaskTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/onboarding-task-templates/{code}": {
      "get": {
        "tags": [
          "Service - Onboarding Tasks"
        ],
        "summary": "Get OnboardingTaskTemplate",
        "description": "Gets a OnboardingTaskTemplate for the specified tenant.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetOnboardingTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingTaskTemplateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Service - Onboarding Tasks"
        ],
        "summary": "Update OnboardingTaskTemplate",
        "description": "Updates a OnboardingTaskTemplate for the specified tenant.\n\nRequires: Update on Tasks.",
        "operationId": "UpdateOnboardingTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOnboardingTaskTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingTaskTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Service - Onboarding Tasks"
        ],
        "summary": "Delete OnboardingTaskTemplate",
        "description": "Deletes a OnboardingTaskTemplate for the specified tenant.\n\nRequires: Delete on Tasks.",
        "operationId": "DeleteOnboardingTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/onboarding-task-templates/{code}/library-version": {
      "put": {
        "tags": [
          "Service - Onboarding Tasks"
        ],
        "summary": "Revert OnboardingTaskTemplate to Library",
        "description": "Reverts the OnboardingTaskTemplate to the current library template version, overwriting any local edits. The OnboardingTaskTemplate's code is preserved so it remains addressable at the same URL. Returns 400 if the OnboardingTaskTemplate was not imported from the library, or 404 if the OnboardingTaskTemplate or its source library template no longer exists.\n\nRequires: Update on Tasks.",
        "operationId": "RevertOnboardingTaskTemplateToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingTaskTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/service-packages": {
      "get": {
        "tags": [
          "Service - Packages"
        ],
        "summary": "List ServicePackages",
        "description": "Lists all ServicePackages for the given tenant.\n\nRequires: ViewAll on ServicePackages.",
        "operationId": "ListServicePackages",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ServicePackageSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - returns packages containing any of the specified services",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SVC-001\", \"SVC-002\" ]"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServicePackageDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ServicePackages",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Service - Packages"
        ],
        "summary": "Create ServicePackage",
        "description": "Creates a new ServicePackage for the specified tenant.\n\nRequires: Create on ServicePackages.",
        "operationId": "CreateServicePackage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateServicePackageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServicePackageDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ServicePackages",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/service-packages/{code}": {
      "get": {
        "tags": [
          "Service - Packages"
        ],
        "summary": "Get ServicePackage",
        "description": "Gets a ServicePackage for the specified tenant.\n\nRequires: ViewAll on ServicePackages.",
        "operationId": "GetServicePackage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServicePackageDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ServicePackages",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Service - Packages"
        ],
        "summary": "Update ServicePackage",
        "description": "Updates a ServicePackage for the specified tenant.\n\nRequires: Update on ServicePackages.",
        "operationId": "UpdateServicePackage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateServicePackageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServicePackageDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ServicePackages",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Service - Packages"
        ],
        "summary": "Delete ServicePackage",
        "description": "Deletes a ServicePackage for the specified tenant.\n\nRequires: Delete on ServicePackages.",
        "operationId": "DeleteServicePackage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ServicePackages",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/service-packages/{code}/bulk-apply": {
      "post": {
        "tags": [
          "Service - Packages"
        ],
        "summary": "Bulk Apply Package",
        "description": "Applies this service package to multiple clients at once. Creates ClientBillableService records for each package item for each client.\n\nRequires: Create on ClientBillableServices.",
        "operationId": "BulkApplyServicePackageToClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkApplyServicePackageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkAssignResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/clients/{clientCode}/apply-service-package/{packageCode}": {
      "post": {
        "tags": [
          "Service - Packages"
        ],
        "summary": "Apply Service Package to Client",
        "description": "Applies a service package to a client, creating ClientBillableService records for each item in the package.\n\nRequires: Create on ClientBillableServices.",
        "operationId": "ApplyServicePackageToClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "packageCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyServicePackageRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientBillableServiceDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Create"
          }
        ]
      },
      "delete": {
        "tags": [
          "Service - Packages"
        ],
        "summary": "Remove Service Package from Client",
        "description": "Removes all client billable services linked to the specified service package.\n\nRequires: Delete on ClientBillableServices.",
        "operationId": "RemoveServicePackageFromClient",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "packageCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/services": {
      "get": {
        "tags": [
          "Services"
        ],
        "summary": "List BillableServices",
        "description": "Lists all BillableServices for the given tenant.\n\nRequires: ViewAll on BillableServices.",
        "operationId": "ListBillableServices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/BillableServiceSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "categoryCode",
            "in": "query",
            "description": "Filter services by category code",
            "schema": {
              "type": "string",
              "example": "core-accounting"
            }
          },
          {
            "name": "clientType",
            "in": "query",
            "description": "Filter services by client type they are applicable to",
            "schema": {
              "enum": [
                "PrivateLimitedCompany",
                "PublicLimitedCompany",
                "LimitedLiabilityPartnership",
                "Partnership",
                "Individual",
                "Trust",
                "Charity",
                "SoleTrader",
                "Association"
              ],
              "type": "string",
              "example": "Individual"
            }
          },
          {
            "name": "isArchived",
            "in": "query",
            "description": "Filter by archived status (true = archived only, false = active only)",
            "schema": {
              "type": "boolean",
              "example": "false"
            }
          },
          {
            "name": "hasStages",
            "in": "query",
            "description": "Filter to only services that have stages defined (true = with stages only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "hasPricingFactors",
            "in": "query",
            "description": "Filter to only services that have pricing factors defined (true = with pricing factors only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "showKanbanBoard",
            "in": "query",
            "description": "Filter to only services with kanban board enabled (true = kanban-enabled only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "hasPreparerRole",
            "in": "query",
            "description": "Filter by whether clients on the service have a Preparer (true = with a Preparer role only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "hasReviewerRole",
            "in": "query",
            "description": "Filter by whether clients on the service have a Reviewer (true = with a Reviewer role only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "requiredProduct",
            "in": "query",
            "description": "Filter to services that require this Sodium product",
            "schema": {
              "enum": [
                "CisManager",
                "Mtd"
              ],
              "type": "string",
              "example": "CisManager"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across service code and name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "tax"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillableServiceDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Services"
        ],
        "summary": "Create BillableService",
        "description": "Creates a new BillableService for the specified tenant.\n\nRequires: Create on BillableServices.",
        "operationId": "CreateBillableService",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBillableServiceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillableServiceDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/{code}": {
      "get": {
        "tags": [
          "Services"
        ],
        "summary": "Get BillableService",
        "description": "Gets a BillableService for the specified tenant.\n\nRequires: ViewAll on BillableServices.",
        "operationId": "GetBillableService",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillableServiceDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Services"
        ],
        "summary": "Update BillableService",
        "description": "Updates a BillableService for the specified tenant.\n\nRequires: Update on BillableServices.",
        "operationId": "UpdateBillableService",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateBillableServiceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillableServiceDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Services"
        ],
        "summary": "Delete BillableService",
        "description": "Deletes a BillableService for the specified tenant.\n\nRequires: Delete on BillableServices.",
        "operationId": "DeleteBillableService",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/library": {
      "get": {
        "tags": [
          "Services"
        ],
        "summary": "List Library BillableServices",
        "description": "List all BillableServices available in the library as templates. Use optional 'search' query parameter to filter by Code, Name, or Description.\n\nRequires: ViewAll on BillableServices.",
        "operationId": "ListLibraryBillableServices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BillableServiceDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/library/{code}": {
      "get": {
        "tags": [
          "Services"
        ],
        "summary": "Get Library BillableService",
        "description": "Get details of a specific BillableService template from the library\n\nRequires: ViewAll on BillableServices.",
        "operationId": "GetLibraryBillableService",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillableServiceDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/{code}/library-version": {
      "put": {
        "tags": [
          "Services"
        ],
        "summary": "Revert BillableService to Library",
        "description": "Reverts the BillableService to the current library template version, overwriting any local edits. The BillableService's code is preserved so it remains addressable at the same URL. Returns 400 if the BillableService was not imported from the library, or 404 if the BillableService or its source library template no longer exists.\n\nRequires: Update on BillableServices.",
        "operationId": "RevertBillableServiceToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillableServiceDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/library/import": {
      "post": {
        "tags": [
          "Services"
        ],
        "summary": "Import Services from Library",
        "description": "Creates one or more BillableServices for the tenant based on library templates.\n\nRequires: Create on BillableServices.",
        "operationId": "ImportBillableServicesFromLibrary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportBillableServicesFromLibraryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BillableServiceDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/generate": {
      "post": {
        "tags": [
          "Services"
        ],
        "summary": "Generate Service",
        "description": "Generates a complete BillableService DTO with AI-generated content based on the service name\n\nRequires: Create on BillableServices.",
        "operationId": "GenerateBillableService",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateBillableServiceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillableServiceDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/{code}/generatefactors": {
      "post": {
        "tags": [
          "Services"
        ],
        "summary": "Generate Pricing Factors",
        "description": "Generates pricing factor questions and options for an existing service using AI\n\nRequires: Update on BillableServices.",
        "operationId": "GeneratePricingFactors",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PricingFactorDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/{code}/required-client-fields": {
      "get": {
        "tags": [
          "Services"
        ],
        "summary": "Get Required Client Fields for Service",
        "description": "Returns client fields that are required by recurring tasks linked to this service.\n\nRequires: ViewAll on BillableServices.",
        "operationId": "GetRequiredClientFieldsForService",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientCsvTargetField"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/{code}/bill-for-work-coverage": {
      "get": {
        "tags": [
          "Services"
        ],
        "summary": "Get Bill for Work Coverage",
        "description": "Returns whether an active recurring task for this service uses a workflow with a Bill for Work step, which is what bills a service set to bill when the work is done.\n\nRequires: ViewAll on BillableServices.",
        "operationId": "GetServiceBillForWorkCoverage",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceBillForWorkCoverageDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/{code}/clients/bulk-assign": {
      "post": {
        "tags": [
          "Services"
        ],
        "summary": "Bulk Assign Service",
        "description": "Assigns this billable service to multiple clients at once. Optionally creates onboarding tasks for each new assignment.\n\nRequires: Create on ClientBillableServices.",
        "operationId": "BulkAssignServiceToClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkAssignServiceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkAssignResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/{code}/clients/bulk-update": {
      "patch": {
        "tags": [
          "Services"
        ],
        "summary": "Bulk Update Client Services",
        "description": "Updates fields across multiple client service assignments belonging to this service. Assignments belonging to a different service are ignored. Only provided (non-null) fields are changed.\n\nRequires: Update on ClientBillableServices.",
        "operationId": "BulkUpdateClientServices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkUpdateClientServicesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceBulkUpdateResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/{code}/clients/bulk-remove": {
      "post": {
        "tags": [
          "Services"
        ],
        "summary": "Bulk Remove Client Services",
        "description": "Removes multiple client service assignments belonging to this service. Assignments belonging to a different service are ignored. Fails if any have billing line items.\n\nRequires: Delete on ClientBillableServices.",
        "operationId": "BulkRemoveClientServices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkRemoveClientServicesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeleteResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBillableServices",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/import/csv/analyze": {
      "post": {
        "tags": [
          "Services - Import"
        ],
        "summary": "Analyze Services CSV",
        "description": "Auto-detects the format of a services catalog CSV (native Sodium export or Ignition export) and returns preview rows for review. Stateless: no data is persisted.\n\nRequires: Import on BillableServices.",
        "operationId": "AnalyzeServiceCatalogCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ServiceCatalogImportRowDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/import/csv": {
      "post": {
        "tags": [
          "Services - Import"
        ],
        "summary": "Import Services CSV",
        "description": "Re-uploads an analyzed services catalog CSV with the user's selections and creates or updates billable services, plus deduplicated Service Terms content blocks. Returns per-row results.\n\nRequires: Import on BillableServices.",
        "operationId": "ImportServiceCatalogCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file",
                  "selections"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "selections": {
                    "type": "string"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                },
                "selections": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCatalogImportResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/services/import/csv/export": {
      "get": {
        "tags": [
          "Services - Import"
        ],
        "summary": "Export Services CSV",
        "description": "Downloads the billable services catalog as a native-format CSV, including each service's terms HTML. Re-importing the file updates services matched by Code. Use this as the template for the native import format.\n\nRequires: Export on BillableServices.",
        "operationId": "ExportServiceCatalogCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "BillableServices",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/products/cis-manager/connect": {
      "post": {
        "tags": [
          "Sodium Apps"
        ],
        "summary": "Connect CIS Manager",
        "description": "Connects the practice to CIS Manager without creating any client organisation: its CIS Manager practice is provisioned on the first call, and the signed-in user joins it. The two CIS Manager email templates are imported from the library when the practice has no copy, and set in the CIS Manager settings where none is chosen. Repeating it is safe.\n\nRequires: Create on ProductAccounts.",
        "operationId": "ConnectCisManager",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/products/cis-manager/link-request": {
      "post": {
        "tags": [
          "Sodium Apps"
        ],
        "summary": "Request CIS Manager Practice Link",
        "description": "Asks Sodium support to link the practice the signed-in user already runs in CIS Manager to this practice, instead of a second one being set up: what the dialog offers when connecting answers 409 with errorCode cis_manager_practice_exists. Support is emailed, and links it from Admin. 409 when this practice is already connected to CIS Manager, or the user runs no practice there.\n\nRequires: Create on ProductAccounts.",
        "operationId": "RequestCisManagerPracticeLink",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/cis-manager-settings": {
      "get": {
        "tags": [
          "Sodium Apps"
        ],
        "summary": "Get CIS Manager Settings",
        "description": "Returns the practice's CIS Manager settings: the email templates the Collect CIS payments and Confirm CIS return steps send with\n\nRequires: ViewAll on ProductAccounts.",
        "operationId": "GetCISManagerSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CisManagerSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Sodium Apps"
        ],
        "summary": "Update CIS Manager Settings",
        "description": "Updates the practice's CIS Manager settings. A full replacement: a template left out is cleared, and the CIS Manager client steps then block until one is chosen\n\nRequires: Update on ProductAccounts.",
        "operationId": "UpdateCISManagerSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCisManagerSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CisManagerSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ProductAccounts",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription": {
      "get": {
        "tags": [
          "Subscription"
        ],
        "summary": "Get Current Subscription",
        "description": "Returns the current active subscription for the tenant\n\nRequires: ViewAll on Subscription.",
        "operationId": "GetCurrentSubscription",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Subscription",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Subscription"
        ],
        "summary": "Change Subscription",
        "description": "Changes the tenant's subscription to a different package. The pricing tier is automatically determined based on the tenant's active client count. If the subscription was previously cancelled, choosing a new package will clear the cancellation.\n\nRequires: Admin on Subscription.",
        "operationId": "ChangeSubscription",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeSubscriptionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Subscription",
            "permission": "Admin"
          }
        ]
      },
      "delete": {
        "tags": [
          "Subscription"
        ],
        "summary": "Cancel Subscription",
        "description": "Cancels the tenant's subscription. During a free trial, this removes the pending package selection (the trial continues and will expire naturally). Outside of a trial, this ends the current subscription immediately and marks the tenant as cancelled — the tenant will be auto-downgraded to the appropriate tier based on their client count. To reactivate after cancellation, choose a new package via PUT which clears the cancellation flag.\n\nRequires: Admin on Subscription.",
        "operationId": "CancelSubscription",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Subscription",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/history": {
      "get": {
        "tags": [
          "Subscription"
        ],
        "summary": "Get Subscription History",
        "description": "Returns all subscriptions for the tenant, including historical\n\nRequires: ViewAll on Subscription.",
        "operationId": "GetSubscriptionHistory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SubscriptionDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Subscription",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/price-preview": {
      "get": {
        "tags": [
          "Subscription"
        ],
        "summary": "Preview Subscription Prices",
        "description": "Returns the price for each available package based on the tenant's current active client count, including any active discount.\n\nRequires: ViewAll on Subscription.",
        "operationId": "PreviewSubscriptionPrice",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SubscriptionPricePreviewDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Subscription",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/user-billing": {
      "get": {
        "tags": [
          "Subscription"
        ],
        "summary": "Get User Billing Summary",
        "description": "Returns the tenant's per-user billing position: how many users are included in the subscription, the current billable user count (active and invited users), and the estimated monthly charge for any users above the included allowance.\n\nRequires: ViewAll on Subscription.",
        "operationId": "GetUserBillingSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserBillingSummaryDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Subscription",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/billing": {
      "get": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "Get Billing Account",
        "description": "Returns the billing account linked to this tenant, or 404 if billing has not been set up.\n\nRequires: Admin on Billing.",
        "operationId": "GetBillingAccount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingAccountResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      },
      "post": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "Start Subscription Billing",
        "description": "Creates a billing account for the tenant. The billing account name is set from the tenant name and the billing contact is set to the current user.\n\nRequires: Admin on Billing.",
        "operationId": "StartSubscriptionBilling",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartSubscriptionBillingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingAccountResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      },
      "put": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "Update Billing Account",
        "description": "Updates the billing account's address and invoice recipients. Name and billing contact are not changeable.\n\nRequires: Admin on Billing.",
        "operationId": "UpdateBillingAccount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSubscriptionBillingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingAccountResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/billing/mandate-setup": {
      "post": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "Initiate Mandate Setup",
        "description": "Starts a GoCardless Direct Debit mandate setup. Returns a URL to redirect the user to for authorisation. If setup was already initiated in the last few minutes, returns the existing pending flow's URL instead of creating a new one.\n\nRequires: Admin on Billing.",
        "operationId": "InitiateMandateSetup",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InitiateMandateSetupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MandateSetupResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/billing/mandate-setup/complete": {
      "post": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "Complete Mandate Setup",
        "description": "Completes the GoCardless Direct Debit mandate setup after the user has authorised it.\n\nRequires: Admin on Billing.",
        "operationId": "CompleteMandateSetup",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompleteMandateSetupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentMandateResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/billing/mandate/cancel": {
      "post": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "Cancel Mandate",
        "description": "Cancels the active Direct Debit mandate for the tenant's billing account.\n\nRequires: Admin on Billing.",
        "operationId": "CancelMandate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/billing/mandate/refresh": {
      "get": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "Refresh Mandate Status",
        "description": "Fetches the current mandate status from GoCardless and updates the local record.\n\nRequires: Admin on Billing.",
        "operationId": "RefreshMandateStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentMandateResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/billing/invoices": {
      "get": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "List Invoices",
        "description": "Returns a paginated list of invoices for the tenant's billing account with optional filtering by status and date range.\n\nRequires: Admin on Billing.",
        "operationId": "ListInvoices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "status",
            "in": "query",
            "description": "Defines the status of a billing invoice.",
            "schema": {
              "$ref": "#/components/schemas/BillingInvoiceStatus"
            },
            "x-order": 200
          },
          {
            "name": "fromDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "toDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "type": "string",
              "example": "Name"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceSummaryResponsePagedResult"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/billing/invoices/{code}/pdf": {
      "get": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "Download Invoice PDF",
        "description": "Downloads the invoice PDF. Returns 404 if the PDF has not been generated.\n\nRequires: Admin on Billing.",
        "operationId": "DownloadInvoicePdf",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/billing/invoices/{code}": {
      "get": {
        "tags": [
          "Subscription - Billing"
        ],
        "summary": "Get Invoice",
        "description": "Returns the full invoice detail including line items. Use code 'draft' to get the current draft invoice.\n\nRequires: Admin on Billing.",
        "operationId": "GetInvoice",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Billing",
            "permission": "Admin"
          }
        ]
      }
    },
    "/tenants/{tenant}/subscription/discount": {
      "get": {
        "tags": [
          "Subscription - Discounts"
        ],
        "summary": "Get Active Discount",
        "description": "Returns the currently active subscription discount for the tenant, or 404 if no discount is active.\n\nRequires: ViewAll on Subscription.",
        "operationId": "GetActiveDiscount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionDiscountDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Subscription",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Subscription - Discounts"
        ],
        "summary": "Redeem Discount Code",
        "description": "Redeems a discount code for this tenant's subscription billing. The tenant must not already have an active discount.\n\nRequires: Admin on Subscription.",
        "operationId": "RedeemDiscountCode",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RedeemDiscountCodeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionDiscountDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Subscription",
            "permission": "Admin"
          }
        ]
      },
      "delete": {
        "tags": [
          "Subscription - Discounts"
        ],
        "summary": "Remove Discount",
        "description": "Removes the active discount from this tenant, allowing a different discount code to be applied.\n\nRequires: Admin on Subscription.",
        "operationId": "RemoveDiscount",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Subscription",
            "permission": "Admin"
          }
        ]
      }
    },
    "/packages": {
      "get": {
        "tags": [
          "Subscription - Packages"
        ],
        "summary": "List Packages",
        "description": "Lists all packages.",
        "operationId": "GetPackages",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PackageDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/packages/{code}": {
      "get": {
        "tags": [
          "Subscription - Packages"
        ],
        "summary": "Get Package",
        "description": "Gets a specific package by its code.",
        "operationId": "GetPackage",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PackageDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/packages/{code}/pricing": {
      "get": {
        "tags": [
          "Subscription - Packages"
        ],
        "summary": "List Pricing Tiers for Package",
        "description": "Lists all available pricing tiers for a specific package.",
        "operationId": "GetPackagePricingTiers",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PricingTierDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/pricing/tiers/{packageCode}/{clientCount}": {
      "get": {
        "tags": [
          "Subscription - Packages"
        ],
        "summary": "Get Pricing Tier",
        "description": "Returns the applicable pricing tier for a given package and client count. Anonymous endpoint for public pricing pages.",
        "operationId": "GetPricingTierForClientCount",
        "parameters": [
          {
            "name": "clientCount",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "packageCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PricingTierDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/emails": {
      "get": {
        "tags": [
          "Task - Emails"
        ],
        "summary": "List Emails for Task",
        "description": "Returns email conversations that have been explicitly linked to this task.\n\nRequires: ViewAll on Mailbox.",
        "operationId": "GetTaskEmails",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxThreadSummaryDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Mailbox",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/taskitemnote": {
      "get": {
        "tags": [
          "Task - Notes"
        ],
        "summary": "List Notes for Task",
        "description": "Lists notes for the specified task. By default only returns task-level notes. Set includeStepNotes=true to also include notes attached to workflow steps.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListTaskItemNotes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "includeStepNotes",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TaskItemNoteSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Task - Notes"
        ],
        "summary": "Create Note",
        "description": "Creates a new note for the specified task.\n\nRequires: Update on Tasks.",
        "operationId": "CreateTaskItemNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTaskItemNoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/taskitemnote/pinned": {
      "get": {
        "tags": [
          "Task - Notes"
        ],
        "summary": "Get Pinned Notes for Task",
        "description": "Gets pinned notes for the specified task (PinnedLevel > 0), ordered by PinnedLevel descending. By default only returns task-level pinned notes. Set includeStepNotes=true to also include notes attached to workflow steps.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetPinnedTaskItemNotes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "includeStepNotes",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NoteDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/taskitemnote/{code}": {
      "get": {
        "tags": [
          "Task - Notes"
        ],
        "summary": "Get Note by Code",
        "description": "Gets a specific note for the task by its code.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetTaskItemNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Task - Notes"
        ],
        "summary": "Update Note",
        "description": "Updates an existing note for the specified task.\n\nRequires: Update on Tasks.",
        "operationId": "UpdateTaskItemNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTaskItemNoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Task - Notes"
        ],
        "summary": "Delete Note",
        "description": "Deletes a note from the specified task.\n\nRequires: Update on Tasks.",
        "operationId": "DeleteTaskItemNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/groups/{groupNumber}/steps/{stepNumber}/notes": {
      "get": {
        "tags": [
          "Task - Workflow Notes"
        ],
        "summary": "List Notes for Workflow Step",
        "description": "Lists all notes for the specified workflow step.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListStepNotes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TaskItemNoteSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Task - Workflow Notes"
        ],
        "summary": "Create Note for Workflow Step",
        "description": "Creates a new note for the specified workflow step.\n\nRequires: Update on Tasks.",
        "operationId": "CreateStepNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTaskItemNoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/groups/{groupNumber}/steps/{stepNumber}/notes/pinned": {
      "get": {
        "tags": [
          "Task - Workflow Notes"
        ],
        "summary": "Get Pinned Notes for Workflow Step",
        "description": "Gets all pinned notes for the specified workflow step (PinnedLevel > 0), ordered by PinnedLevel descending.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetPinnedStepNotes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NoteDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/groups/{groupNumber}/steps/{stepNumber}/notes/{code}": {
      "get": {
        "tags": [
          "Task - Workflow Notes"
        ],
        "summary": "Get Note by Code",
        "description": "Gets a specific note for the workflow step by its code.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetStepNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Task - Workflow Notes"
        ],
        "summary": "Update Note for Workflow Step",
        "description": "Updates an existing note for the specified workflow step.\n\nRequires: Update on Tasks.",
        "operationId": "UpdateStepNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTaskItemNoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Task - Workflow Notes"
        ],
        "summary": "Delete Note from Workflow Step",
        "description": "Deletes a note from the specified workflow step.\n\nRequires: Update on Tasks.",
        "operationId": "DeleteStepNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow": {
      "post": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Set Task Workflow",
        "description": "Initializes workflow step instances for a TaskItem based on a workflow template.\n            \nCreates progress tracking records for each step in the specified workflow:\n- Creates TaskItemWorkflowStep instances for all workflow steps\n- Sets initial assignments based on workflow template rules\n- Resets progress counters and status to starting values\n- Clears any existing workflow progress\n            \n**Warning: This operation clears all existing workflow progress.**\nAny completed steps will be lost and the workflow will restart from the beginning.\n            \nUse this endpoint to:\n- Assign a workflow to a task for the first time\n- Change the workflow assigned to a task\n- Reset workflow progress to start over\n- Set up workflow tracking for imported tasks\n            \nThe workflow template defines:\n- Which steps are created\n- Initial step assignments\n- Step dependencies and ordering\n- Default completion requirements\n            \nExample Request:\n{\n  \"workflowCode\": \"CLIENT-ONBOARDING\"\n}\n\nRequires: Update on Tasks.",
        "operationId": "InitializeWorkflowSteps",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "taskCode",
            "in": "path",
            "description": "The task code from the URL",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "description": "The workflow initialization request",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InitializeWorkflowStepsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkflowStepProgressDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Remove Task Workflow",
        "description": "Clears all workflow step progress for a TaskItem.\n            \nRemoves all workflow progress tracking:\n- Deletes all TaskItemWorkflowStep instances\n- Resets workflow progress counters to zero\n- Clears workflow reference from the task\n- Removes all step assignments and completion data\n            \nUse this endpoint to:\n- Remove workflow tracking from a task\n- Clear progress before assigning a different workflow\n- Reset workflow progress completely\n- Clean up workflow data for completed tasks\n            \n**Warning: This operation cannot be undone.**\nAll workflow progress data will be permanently lost.\n            \nAfter clearing, the task will have no workflow assigned\nand workflow progress fields will be reset to null/zero.\n\nRequires: Update on Tasks.",
        "operationId": "ClearWorkflowSteps",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "taskCode",
            "in": "path",
            "description": "The task code from the URL",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups": {
      "get": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Get Task Workflow Groups",
        "description": "Retrieves comprehensive workflow progress information for a TaskItem.\n            \nReturns detailed progress data including:\n- Overall completion statistics (total steps, completed steps, percentage)\n- All workflow steps with current status and assignments\n- Available steps that can be worked on next\n- Steps grouped by workflow groups for organized display\n            \nUse this endpoint to:\n- Display workflow progress dashboards\n- Show step-by-step task execution status\n- Identify bottlenecks and available work\n- Track overall workflow completion\n            \nExample Response:\n{\n  \"totalSteps\": 8,\n  \"completedSteps\": 3,\n  \"progressPercentage\": 37.5,\n  \"allSteps\": [...],\n  \"availableSteps\": [...],\n  \"groupedSteps\": [...]\n}\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetTaskWorkflowGroups",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "taskCode",
            "in": "path",
            "description": "The task code from the URL",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkflowGroupProgressDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}": {
      "get": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Get Workflow Step",
        "description": "Retrieves a single workflow step with current status and execution details.\n            \nUse this endpoint to:\n- Check execution status after calling the Execute endpoint\n- Monitor SendEmail step progress (email sent status, message ID)\n- Query step details without loading all workflow groups\n- Poll for execution completion\n            \nFor SendEmail steps, the emailExecutionState property will be populated\nwhen the email has been sent, containing the emailMessageId and sentAt timestamp.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetWorkflowStep",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "description": "The group number (sort order) from the URL",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "description": "The step number from the URL",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "description": "The task code from the URL",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepProgressDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Update Workflow Step",
        "description": "Updates workflow step properties including status, assignment, and email configuration.\n            \nSupports updating:\n- Status changes (validates dependencies)\n- User assignment\n- Email configuration (SendEmail steps only, before execution)\n            \nEmail configuration uses PUT semantics - when provided, all fields must be included.\nConfiguration can only be updated on SendEmail steps that are not Completed status.\n            \nExample Request:\n{\n  \"status\": \"Completed\"\n}\n\nRequires: Update on Tasks.",
        "operationId": "UpdateWorkflowStep",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "description": "The group number (sort order) from the URL",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "description": "The step number to update from the URL",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "description": "The task code from the URL",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "description": "The update request with new values",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkflowStepRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepProgressDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/steps/status": {
      "put": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Set All Workflow Steps Status",
        "description": "Sets every open step of the task's workflow to Completed or Skipped, then returns the\nrefreshed groups so the workflow card can redraw without a second request.\n\nRequires: Update on Tasks.",
        "operationId": "SetAllWorkflowStepsStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetAllWorkflowStepsStatusRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkflowGroupProgressDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/execute": {
      "post": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Execute Workflow Step",
        "description": "Queues a typed workflow step (e.g., SendEmail) for async execution.\n            \nValidation:\n- Step must exist and belong to the tenant\n- StepType must not be Standard (standard steps are manual checklist items)\n- Status must be NotStarted (prevents re-execution of already sent emails)\n- CanStart must be true (all dependency steps completed)\n            \nOn success, a WorkflowStepActionMessage is queued to the workflow-step-action queue\nfor processing by the function app. Returns 202 Accepted immediately.\n\nRequires: Update on Tasks.",
        "operationId": "ExecuteWorkflowStep",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExecuteWorkflowStepRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/send": {
      "post": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Send Workflow Step Email",
        "description": "Sends a user-composed email for a SendEmail workflow step.\nThe email content comes from the request body, not the step's stored config.\nOn success, marks the step as Completed and records execution state.\n\nRequires: Update on Tasks.",
        "operationId": "SendWorkflowStepEmail",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "configCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMailboxEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledSendDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/resend": {
      "post": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Resend Client Confirmation",
        "description": "Emails a client confirmation step that is waiting on the client to the given addresses again, each with a fresh link, using the confirmation email template. Everyone the confirmation already went to keeps their link and keeps being chased, unless stopChasingOthers is set, which makes these the only recipients.\n\nRequires: Update on Tasks.",
        "operationId": "ResendClientConfirmation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResendRequestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/recipients": {
      "get": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Get Client Confirmation Recipients",
        "description": "Returns the email addresses a sent client confirmation step currently counts as its recipients: everyone it was sent to and has not since been withdrawn from. These are the addresses its chases go to.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetClientConfirmationRecipients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestRecipientsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/preview": {
      "get": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Preview Workflow Step Email",
        "description": "Generates a preview of the email that would be sent by a SendEmail workflow step.\nRenders subject and body with resolved Liquid tokens and tenant branding,\nand resolves all To/CC recipients from contacts, users, and static addresses.\nDoes not send the email or change step status.\n\nRequires: ViewAll on Tasks.",
        "operationId": "PreviewWorkflowStepEmail",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepEmailPreviewDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/text-preview": {
      "get": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Preview Workflow Step Text",
        "description": "What a Send Text Message step would do if it ran now: each contact it would text (name, mobile, the text rendered for them, whether the number is known on WhatsApp, and whether an earlier run already texted them), each person it would miss and why (no contact of a type, no mobile, a number that cannot be read, on the do-not-text list), the reasons that would stop it texting anyone (blockers, worded as the blocked step shows them), and heldUntil (UTC) when the step is automatic and a run now would wait for the practice's quiet hours. No cost is shown. Nothing is sent or stored. 400 for a step of another type.\n\nRequires: ViewAll on Tasks.",
        "operationId": "PreviewWorkflowStepText",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepTextPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/client-data": {
      "get": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Get Step Client Data",
        "description": "Returns the current client field values for the fields configured on an UpdateClientData workflow step, along with field metadata for rendering inputs.\n\nRequires: ViewAll on Tasks and ViewAll on Clients.",
        "operationId": "GetWorkflowStepClientData",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepClientDataDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          },
          {
            "entity": "Clients",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Save Step Client Data",
        "description": "Saves client data values from an UpdateClientData workflow step. Applies values to the client record. Set markComplete to true to also mark the step as Completed.\n\nRequires: Update on Clients and Update on Tasks.",
        "operationId": "SaveWorkflowStepClientData",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveWorkflowStepClientDataRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          },
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/review-time-defaults": {
      "get": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Get Review & Bill Time Defaults",
        "description": "Returns the billing line description (tokens rendered for the task and its client) and the accounting code a Review & Bill Time step pre-fills when its time is billed.\n\nRequires: ViewAll on ClientBilling and ViewAll on Tasks.",
        "operationId": "GetReviewLoggedTimeDefaults",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReviewLoggedTimeDefaultsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          },
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/bill-for-work-preview": {
      "get": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Get Bill for Work Preview",
        "description": "Returns what a Bill for Work step will bill if it runs now (amount, service period, rendered line description), or why it cannot bill.\n\nRequires: ViewAll on ClientBilling and ViewAll on Tasks and ViewAll on Clients and ViewAll on ClientBillableServices.",
        "operationId": "GetBillForWorkPreview",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillForWorkPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          },
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          },
          {
            "entity": "Clients",
            "permission": "ViewAll"
          },
          {
            "entity": "ClientBillableServices",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/cis/submit": {
      "post": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Submit CIS Return",
        "description": "\"Submit to HMRC\" on a Submit CIS return step: submits the step's tax month's return through CIS Manager now, as\nthe signed-in user when they hold ProductAccounts view (otherwise as the practice), with the declarations\ngiven (a nil return sends neither). Refused (400) with the reason\nwhen the return has changed since the contractor confirmed it, unless ignoreConfirmedChanges is set. Allowed\nfor a step not started (its dependencies met), blocked, or in progress with a return HMRC rejected; 400\notherwise. A return already submitted or accepted in CIS Manager is not filed again: the step waits on HMRC\nor completes. CIS Manager's refusals (filing credits, unfinished HMRC settings, validation) block the step\nwith the reason and are the 400's message. On success the step is in progress, waiting on HMRC.\n\nRequires: Update on Tasks.",
        "operationId": "SubmitCisReturn",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CisSubmitReturnRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/cis/payments": {
      "post": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Complete CIS Payments",
        "description": "Staff complete a Collect CIS payments step the practice collects, once the team has entered the tax month's\npayments in CIS Manager: the month's payments are read from CIS Manager and their count and totals recorded on\nthe step with the user as submitter, then the step completes and the next steps queue. noPayments declares there were\nnone, and is refused (400) when CIS Manager has payments for the month. Allowed for a step not started (its\ndependencies met) or in progress; 400 for a step collected by the client, or one already finished.\n\nRequires: Update on Tasks.",
        "operationId": "CompleteCisPayments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompleteCisPaymentsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/cis/rate-differences/acknowledge": {
      "post": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Acknowledge CIS Rate Differences",
        "description": "\"Continue anyway\" on a Verify subcontractors step blocked because some of the tax month's payments were made at\nanother rate than HMRC gave the subcontractor (listed in the step state's paidAtDifferentRate; a paid payment is\nnever re-rated): records the signed-in user and the time in the step state (rateDifferencesAcknowledgedByEmail,\nrateDifferencesAcknowledgedAt), completes the step and queues the next steps. 400 for a step that is not a\nVerify subcontractors step, one not blocked for payments at a different rate (or blocked because CIS Manager\nrefused a re-rate, which is fixed in CIS Manager and the step run again), or one that changed meanwhile.\n\nRequires: Update on Tasks.",
        "operationId": "AcknowledgeCisRateDifferences",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{taskCode}/workflow/groups/{groupNumber}/steps/{stepNumber}/cis": {
      "get": {
        "tags": [
          "Task - Workflows"
        ],
        "summary": "Get CIS Step Summary",
        "description": "A summary of a CIS Manager step's tax month as CIS Manager has it, read live for its task card: the month (the\nstep's own once under way, else the task's), the client's organisation, the return with its latest\nsubmission (null when CIS Manager has none for the month) and the payments recorded in the month. 400 for\na step that is not a CIS Manager step, or a client with no CIS Manager organisation (with the reason).\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetCisStepSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "groupNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "stepNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CisStepSummaryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Create TaskItem",
        "description": "Creates a new TaskItem for the specified tenant.\n\nRequires: Create on Tasks.",
        "operationId": "CreateTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTaskItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Create"
          }
        ]
      },
      "delete": {
        "tags": [
          "Tasks"
        ],
        "summary": "Bulk Delete TaskItems",
        "description": "Deletes multiple tasks at once. All tasks must exist.\n\nRequires: Delete on Tasks.",
        "operationId": "BulkDeleteTasks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkDeleteTasksRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeleteResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Delete"
          }
        ]
      },
      "patch": {
        "tags": [
          "Tasks"
        ],
        "summary": "Bulk Update TaskItems",
        "description": "Updates multiple tasks at once. Supports updating status, assigned user, category\nand the automation switch.\n\nAt least one of Status, AssignedUserCode, CategoryCode or IsAutomationDisabled must be provided.\n\n**Automation**: IsAutomationDisabled = true switches automation off; false switches it on,\nwhich immediately runs any workflow steps that are ready. Every code must belong to an\nexisting task - task previews are rejected rather than created.\n\n**Auto-assign behavior**: When setting status to InProgress without specifying an AssignedUserCode,\nany unassigned NotStarted tasks will be automatically assigned to the current user.\n\nRequires: Update on Tasks.",
        "operationId": "BulkUpdateTasks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkUpdateTasksRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      },
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "List TaskItems",
        "description": "Lists TaskItems for the given tenant.\n\n**Date Range Options:**\n- Use dateRange for preset ranges (ThisWeek, ThisMonth, Today, etc.)\n- Use startDate/endDate for custom ranges\n- Date range is required when querying NotStarted tasks (or no status filter) with includeProjected=true — the engine needs a window to project recurrences into\n- Date range is NOT required when includeProjected=false (materialised tasks only)\n- Date range is NOT required when filtering by non-NotStarted statuses only (e.g., InProgress, Completed)\n- Date range is NOT required when using isOverdue=true\n- A date range may span at most 2 years when includeProjected or includeWorkflowSteps is true\n  (those lists are built in memory); otherwise it is unlimited\n\n**Projection Without a Date Range (projectUntil):**\n- Set projectUntil (with includeProjected=true and no date range) to get every existing task\n  plus projected recurrences from today up to that date\n- Only the projected half is bounded — the materialised half stays unbounded, so nothing drops\n  out of the list that a windowless includeProjected=false query would have returned\n- Cannot be combined with a date range (the range already bounds projection) or with isOverdue=true;\n  must be today or later and no more than 2 years ahead\n- A savedFilter that asks for projected tasks but stores no date range gets a 12-month horizon\n  automatically, since a saved view has nowhere to store one\n\n**Overdue Mode (isOverdue=true):**\n- Returns only tasks where DueDate < today\n- Automatically excludes Completed and Skipped statuses unless you specify a status filter\n- No date range required\n\n**Search (search):**\n- Matches the task name, the task code and the primary client's name; minimum 3 characters\n- Secondary client links are not searched — a hit there would return a row whose displayed\n  client does not contain the term\n- **Projected tasks are excluded whenever search is set.** Projected occurrences are generated\n  in memory from a recurrence, so the search cannot be applied to them; leaving projection on\n  would merge unfiltered rows into a searched result. A search therefore needs no date range,\n  whatever includeProjected or projectUntil ask for.\n\n**Standard Mode (includeWorkflowSteps=false, default):**\n- Returns only tasks (materialised and optionally projected)\n- Use dateBasis to specify which date field to use for filtering: StartDate (default) or DueDate\n\n**Agenda Mode (includeWorkflowSteps=true):**\n- Returns both tasks AND workflow steps as TaskItemDto objects\n- Tasks: Returned with all standard TaskItem properties, WorkflowStepDetails = null\n- Workflow Steps: Returned with parent task properties populated, WorkflowStepDetails contains step-specific information\n\nSupports filtering by user(s), client(s), recurring task(s), category, date range, status, and isOverdue.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListTaskItems",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "includeBudget",
            "in": "query",
            "description": "Fill each task's Budget (its period's hours budget and time logged) for callers with Job Budgets. Costs one aggregate query and at most one projection for the page.",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          },
          {
            "name": "savedFilter",
            "in": "query",
            "description": "Code of a saved filter to apply. When provided, all filter parameters from the saved filter are used unless explicitly overridden by query parameters.",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TaskItemSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\", \"CLI-002\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "recurringTask",
            "in": "query",
            "description": "Filter by recurring task code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"REC-001\", \"REC-002\" ]"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\", \"SRV-002\" ]"
            }
          },
          {
            "name": "serviceStage",
            "in": "query",
            "description": "Filter by billable service stage - composite \"serviceCode:stageCode\" values, can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001:STG-001\", \"SRV-002:STG-003\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple. \"__none__\" matches tasks with no category, alone or alongside codes.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\", \"__none__\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "clientManager",
            "in": "query",
            "description": "Filter by the primary client's manager (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "clientPartner",
            "in": "query",
            "description": "Filter by the primary client's partner (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-002\" ]"
            }
          },
          {
            "name": "clientAssociate",
            "in": "query",
            "description": "Filter by the primary client's associate (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-003\" ]"
            }
          },
          {
            "name": "servicePreparer",
            "in": "query",
            "description": "Filter by the Preparer on the task's service (user codes) - can specify multiple. The client's own Preparer, else the service's default. Tasks without a Preparer are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "serviceReviewer",
            "in": "query",
            "description": "Filter by the Reviewer on the task's service (user codes) - can specify multiple. The client's own Reviewer, else the service's default. Tasks without a Reviewer are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-002\" ]"
            }
          },
          {
            "name": "workflow",
            "in": "query",
            "description": "Filter by workflow code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"WFL-001\", \"WFL-002\" ]"
            }
          },
          {
            "name": "stepType",
            "in": "query",
            "description": "Filter by workflow step type(s) - matches tasks with at least one step of these types",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "Standard",
                  "SendEmail",
                  "DocumentRequest",
                  "DocumentApproval",
                  "ClientConfirmation",
                  "SendDataForm",
                  "SetServiceStage",
                  "UpdateClientData",
                  "SetPipelineStage",
                  "DocumentUpload",
                  "ReviewLoggedTime",
                  "BillForWork",
                  "CisCollectPayments",
                  "CisConfirmReturn",
                  "CisSubmitReturn",
                  "CisVerifySubcontractors",
                  "CisFileNilReturn",
                  "CisRemindPayments",
                  "SendTextMessage"
                ],
                "type": "string"
              },
              "example": "[ \"DocumentRequest\", \"ClientConfirmation\" ]"
            }
          },
          {
            "name": "currentStep",
            "in": "query",
            "description": "Filter by current workflow step name(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"Prepare accounts\" ]"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by task status(es)",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "NotStarted",
                  "InProgress",
                  "Blocked",
                  "Completed",
                  "Skipped"
                ],
                "type": "string"
              },
              "example": "[ \"InProgress\", \"Blocked\" ]"
            }
          },
          {
            "name": "includeWorkflowSteps",
            "in": "query",
            "description": "Include workflow steps in the results (default: false). When true, uses Agenda mode.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range. If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Filter tasks starting from this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Filter tasks ending on this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeProjected",
            "in": "query",
            "description": "Include projected (virtual) tasks in the results (default: false)",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "projectUntil",
            "in": "query",
            "description": "Projection horizon for a query with no date range. Requires includeProjected=true and no date range; projects from today to this date while the materialised query stays unbounded.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateBasis",
            "in": "query",
            "description": "Which date field to use as the basis for filtering: StartDate (default) or DueDate",
            "schema": {
              "enum": [
                "Any",
                "StartDate",
                "DueDate",
                "StatutoryDate",
                "CompletedDate"
              ],
              "type": "string"
            }
          },
          {
            "name": "isOverdue",
            "in": "query",
            "description": "Filter to only include overdue tasks (DueDate < today). No date range required when true.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "isUnassigned",
            "in": "query",
            "description": "Include unassigned tasks. Can be combined with user filter to show unassigned OR assigned to specific users.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "isAutomationDisabled",
            "in": "query",
            "description": "True returns only tasks with automation switched off; false only those with it on. Task previews are excluded either way.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across task name, task code and primary client name (minimum 3 characters). Projected tasks are excluded when set.",
            "schema": {
              "type": "string",
              "example": "vat return"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskItemDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{code}": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "Get TaskItem",
        "description": "Gets a TaskItem for the specified tenant.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskItemDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks"
        ],
        "summary": "Update TaskItem",
        "description": "Updates a TaskItem for the specified tenant.\n\nRequires: Update on Tasks.",
        "operationId": "UpdateTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTaskItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Tasks"
        ],
        "summary": "Delete TaskItem",
        "description": "Deletes a TaskItem for the specified tenant.\n\nRequires: Delete on Tasks.",
        "operationId": "DeleteTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Delete"
          }
        ]
      },
      "patch": {
        "tags": [
          "Tasks"
        ],
        "summary": "Patch TaskItem",
        "description": "Updates part of one task, following JSON Merge Patch. Send only the fields to change: a field left\nout is not touched, so a quick action (moving the task on the calendar, a status button, a checklist\ntick) never overwrites details it did not send, such as the description. A field sent as null is\ncleared: description, statutory due date, time estimate, checklist, assignee, team, category, service\nand primary client. The name, status, dates and times are required on a task, so sending one of those\nas null is a 400.\n\n**Clients**: the same rules as a full update. The primary client always stays on the task, and a task\nwith clients but no primary gets its first client as primary. To remove every client, send the client\nlist and the primary client as null. Changing the primary client clears the task's service and\npipeline links (they belong to a client) unless a service code is sent.\n\nThe change is saved through the same update as a full update, so dated workflow steps follow the\ntask when its dates move (unless MoveWorkflowStepDates is false), and colleagues see the change live.\n\nOnly a saved task can be patched. A projected (upcoming) task must be materialised first.\n\nRequires: Update on Tasks.",
        "operationId": "PatchTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchTaskItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/restore": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Bulk Restore Occurrences",
        "description": "Undoes a delete of one or more recurring task occurrences, by the same projected codes\n(proj-{recurringTaskCode}-{clientCode}-{yyyyMMdd}) that deleted them. The Occurrences list\nputs that code on every deleted row.\n\nThis restores the OCCURRENCE, not the task. Deleting a created task deletes it along with its\nnotes, workflow steps and logged time; restoring only lets the schedule produce the date\nagain, and what appears is a fresh task built from the schedule as it stands now. Who deleted\nthe occurrence and who restored it are both kept, and the Occurrences list reports them.\n\nReal task codes are ignored, as are codes naming an occurrence that is not currently deleted,\nso the count returned can be lower than the number of codes submitted.\n\nRequires: Delete on Tasks.",
        "operationId": "BulkRestoreTasks",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkRestoreTasksRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkRestoreResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/date-summary": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "Get Task Date Summary",
        "description": "Returns tasks grouped by date for the requested range: for each date that has tasks,\nthe first perDateLimit tasks (stable order) plus that date's total count. Dates with\nno tasks are omitted.\n\nAccepts the same filters as the task list, including savedFilter, includeProjected and\nincludeWorkflowSteps (agenda mode). Tasks are bucketed by the dateBasis field\n(StartDate when dateBasis is Any). A resolvable date range is required; isOverdue is\nnot supported. NextSteps is not populated on summary responses.\n\nsearch behaves as it does on the task list: it matches task name, task code and primary\nclient name, and excludes projected tasks.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetTaskDateSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "perDateLimit",
            "in": "query",
            "description": "Maximum tasks returned per date (default 10, max 25)",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "x-order": 400
          },
          {
            "name": "savedFilter",
            "in": "query",
            "description": "Code of a saved filter to apply. When provided, all filter parameters from the saved filter are used unless explicitly overridden by query parameters.",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\", \"CLI-002\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "recurringTask",
            "in": "query",
            "description": "Filter by recurring task code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"REC-001\", \"REC-002\" ]"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\", \"SRV-002\" ]"
            }
          },
          {
            "name": "serviceStage",
            "in": "query",
            "description": "Filter by billable service stage - composite \"serviceCode:stageCode\" values, can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001:STG-001\", \"SRV-002:STG-003\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple. \"__none__\" matches tasks with no category, alone or alongside codes.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\", \"__none__\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "clientManager",
            "in": "query",
            "description": "Filter by the primary client's manager (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "clientPartner",
            "in": "query",
            "description": "Filter by the primary client's partner (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-002\" ]"
            }
          },
          {
            "name": "clientAssociate",
            "in": "query",
            "description": "Filter by the primary client's associate (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-003\" ]"
            }
          },
          {
            "name": "servicePreparer",
            "in": "query",
            "description": "Filter by the Preparer on the task's service (user codes) - can specify multiple. The client's own Preparer, else the service's default. Tasks without a Preparer are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "serviceReviewer",
            "in": "query",
            "description": "Filter by the Reviewer on the task's service (user codes) - can specify multiple. The client's own Reviewer, else the service's default. Tasks without a Reviewer are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-002\" ]"
            }
          },
          {
            "name": "workflow",
            "in": "query",
            "description": "Filter by workflow code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"WFL-001\", \"WFL-002\" ]"
            }
          },
          {
            "name": "stepType",
            "in": "query",
            "description": "Filter by workflow step type(s) - matches tasks with at least one step of these types",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "Standard",
                  "SendEmail",
                  "DocumentRequest",
                  "DocumentApproval",
                  "ClientConfirmation",
                  "SendDataForm",
                  "SetServiceStage",
                  "UpdateClientData",
                  "SetPipelineStage",
                  "DocumentUpload",
                  "ReviewLoggedTime",
                  "BillForWork",
                  "CisCollectPayments",
                  "CisConfirmReturn",
                  "CisSubmitReturn",
                  "CisVerifySubcontractors",
                  "CisFileNilReturn",
                  "CisRemindPayments",
                  "SendTextMessage"
                ],
                "type": "string"
              },
              "example": "[ \"DocumentRequest\", \"ClientConfirmation\" ]"
            }
          },
          {
            "name": "currentStep",
            "in": "query",
            "description": "Filter by current workflow step name(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"Prepare accounts\" ]"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by task status(es)",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "NotStarted",
                  "InProgress",
                  "Blocked",
                  "Completed",
                  "Skipped"
                ],
                "type": "string"
              },
              "example": "[ \"InProgress\", \"Blocked\" ]"
            }
          },
          {
            "name": "includeWorkflowSteps",
            "in": "query",
            "description": "Include workflow steps in the results (default: false). When true, uses Agenda mode.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range. If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Filter tasks starting from this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Filter tasks ending on this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeProjected",
            "in": "query",
            "description": "Include projected (virtual) tasks in the results (default: false)",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "projectUntil",
            "in": "query",
            "description": "Projection horizon for a query with no date range. Requires includeProjected=true and no date range; projects from today to this date while the materialised query stays unbounded.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateBasis",
            "in": "query",
            "description": "Which date field to use as the basis for filtering: StartDate (default) or DueDate",
            "schema": {
              "enum": [
                "Any",
                "StartDate",
                "DueDate",
                "StatutoryDate",
                "CompletedDate"
              ],
              "type": "string"
            }
          },
          {
            "name": "isOverdue",
            "in": "query",
            "description": "Filter to only include overdue tasks (DueDate < today). No date range required when true.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "isUnassigned",
            "in": "query",
            "description": "Include unassigned tasks. Can be combined with user filter to show unassigned OR assigned to specific users.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "isAutomationDisabled",
            "in": "query",
            "description": "True returns only tasks with automation switched off; false only those with it on. Task previews are excluded either way.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across task name, task code and primary client name (minimum 3 characters). Projected tasks are excluded when set.",
            "schema": {
              "type": "string",
              "example": "vat return"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskDateSummaryDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/workload-summary": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "Get Task Workload Summary",
        "description": "Returns the four standard workload bucket counts in one call: overdue, due today,\ndue this week, and in progress.\n\nAccepts the task list's scope filters (user, team, isUnassigned, client, category,\nservice, workflow and includeProjected). Date, status, isOverdue, search and\nincludeWorkflowSteps parameters are rejected — the buckets define their own dates\nand statuses, and count a scope rather than a search.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetTaskWorkloadSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\", \"CLI-002\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "recurringTask",
            "in": "query",
            "description": "Filter by recurring task code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"REC-001\", \"REC-002\" ]"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\", \"SRV-002\" ]"
            }
          },
          {
            "name": "serviceStage",
            "in": "query",
            "description": "Filter by billable service stage - composite \"serviceCode:stageCode\" values, can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001:STG-001\", \"SRV-002:STG-003\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple. \"__none__\" matches tasks with no category, alone or alongside codes.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\", \"__none__\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "clientManager",
            "in": "query",
            "description": "Filter by the primary client's manager (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "clientPartner",
            "in": "query",
            "description": "Filter by the primary client's partner (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-002\" ]"
            }
          },
          {
            "name": "clientAssociate",
            "in": "query",
            "description": "Filter by the primary client's associate (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-003\" ]"
            }
          },
          {
            "name": "servicePreparer",
            "in": "query",
            "description": "Filter by the Preparer on the task's service (user codes) - can specify multiple. The client's own Preparer, else the service's default. Tasks without a Preparer are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "serviceReviewer",
            "in": "query",
            "description": "Filter by the Reviewer on the task's service (user codes) - can specify multiple. The client's own Reviewer, else the service's default. Tasks without a Reviewer are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-002\" ]"
            }
          },
          {
            "name": "workflow",
            "in": "query",
            "description": "Filter by workflow code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"WFL-001\", \"WFL-002\" ]"
            }
          },
          {
            "name": "stepType",
            "in": "query",
            "description": "Filter by workflow step type(s) - matches tasks with at least one step of these types",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "Standard",
                  "SendEmail",
                  "DocumentRequest",
                  "DocumentApproval",
                  "ClientConfirmation",
                  "SendDataForm",
                  "SetServiceStage",
                  "UpdateClientData",
                  "SetPipelineStage",
                  "DocumentUpload",
                  "ReviewLoggedTime",
                  "BillForWork",
                  "CisCollectPayments",
                  "CisConfirmReturn",
                  "CisSubmitReturn",
                  "CisVerifySubcontractors",
                  "CisFileNilReturn",
                  "CisRemindPayments",
                  "SendTextMessage"
                ],
                "type": "string"
              },
              "example": "[ \"DocumentRequest\", \"ClientConfirmation\" ]"
            }
          },
          {
            "name": "currentStep",
            "in": "query",
            "description": "Filter by current workflow step name(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"Prepare accounts\" ]"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by task status(es)",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "NotStarted",
                  "InProgress",
                  "Blocked",
                  "Completed",
                  "Skipped"
                ],
                "type": "string"
              },
              "example": "[ \"InProgress\", \"Blocked\" ]"
            }
          },
          {
            "name": "includeWorkflowSteps",
            "in": "query",
            "description": "Include workflow steps in the results (default: false). When true, uses Agenda mode.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range. If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Filter tasks starting from this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Filter tasks ending on this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeProjected",
            "in": "query",
            "description": "Include projected (virtual) tasks in the results (default: false)",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "projectUntil",
            "in": "query",
            "description": "Projection horizon for a query with no date range. Requires includeProjected=true and no date range; projects from today to this date while the materialised query stays unbounded.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateBasis",
            "in": "query",
            "description": "Which date field to use as the basis for filtering: StartDate (default) or DueDate",
            "schema": {
              "enum": [
                "Any",
                "StartDate",
                "DueDate",
                "StatutoryDate",
                "CompletedDate"
              ],
              "type": "string"
            }
          },
          {
            "name": "isOverdue",
            "in": "query",
            "description": "Filter to only include overdue tasks (DueDate < today). No date range required when true.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "isUnassigned",
            "in": "query",
            "description": "Include unassigned tasks. Can be combined with user filter to show unassigned OR assigned to specific users.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "isAutomationDisabled",
            "in": "query",
            "description": "True returns only tasks with automation switched off; false only those with it on. Task previews are excluded either way.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across task name, task code and primary client name (minimum 3 characters). Projected tasks are excluded when set.",
            "schema": {
              "type": "string",
              "example": "vat return"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskWorkloadSummaryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{code}/tax-month": {
      "put": {
        "tags": [
          "Tasks"
        ],
        "summary": "Change Task Tax Month",
        "description": "Sets the tax month the task is for, given as the 5th it ends on (any other day is a 400). The month\nnames the period in everything the task and its steps render ({{ TaxMonth.* }} and the other period\ntokens), in place of the task's start date, and is the month its CIS Manager steps work on. Applying a\nworkflow with CIS Manager steps fixes it from the due date and the steps' tax month choice, and an edited\ndue date does not move it: this is the one way to. A CIS step already under way keeps the month in its\nown state, so the change is refused (400, naming the steps) while a CIS step that has started and not\nfinished is on another month. The month must be within 12 months of today.\n\nRequires: Update on Tasks.",
        "operationId": "SetTaskTaxMonth",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetTaxMonthRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/{code}/history": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "Get TaskItem History",
        "description": "Returns the task's history timeline, newest first — every status and assignee\nchange on the task and its workflow steps, with who made each change.\nDerived from the temporal history of TaskItem and TaskItemWorkflowStep.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetTaskItemHistory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskItemHistoryEventDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-categories": {
      "get": {
        "tags": [
          "Tasks - Categories"
        ],
        "summary": "List TaskCategories",
        "description": "Lists all TaskCategories for the given tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "ListTaskCategories",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TaskCategorySortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskCategoryDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Tasks - Categories"
        ],
        "summary": "Create TaskCategory",
        "description": "Creates a new TaskCategory for the specified tenant.\n\nRequires: Create on PracticeDetails.",
        "operationId": "CreateTaskCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTaskCategoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskCategoryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-categories/{code}": {
      "get": {
        "tags": [
          "Tasks - Categories"
        ],
        "summary": "Get TaskCategory",
        "description": "Gets a TaskCategory for the specified tenant.\n\nRequires: ViewAll on PracticeDetails.",
        "operationId": "GetTaskCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskCategoryDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks - Categories"
        ],
        "summary": "Update TaskCategory",
        "description": "Updates a TaskCategory for the specified tenant.\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateTaskCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTaskCategoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskCategoryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Tasks - Categories"
        ],
        "summary": "Delete TaskCategory",
        "description": "Deletes a TaskCategory for the specified tenant.\n\nRequires: Delete on PracticeDetails.",
        "operationId": "DeleteTaskCategory",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/export/csv": {
      "post": {
        "tags": [
          "Tasks - CSV Export"
        ],
        "summary": "Start Tasks CSV Export",
        "description": "Starts an async export of the tasks matching the filter to CSV, one row per task.\n\nAccepts the same filters as the task list (including savedFilter), so the file holds the\ntasks the list shows for that filter, not just one page of them. With no filter, every\ntask is exported. Previews of recurring tasks (includeProjected) and workflow steps\n(includeWorkflowSteps) are never exported. The columns match the task import, with Code\nas the key to update tasks on re-import.\n\nClient visibility applies: a restricted user exports only clientless tasks and tasks for\nclients they can see.\n\nReturns 201 Created with downloadUrl if the export completes within 10 seconds, or 202\nAccepted with a Location header to poll for completion.\n\nRequires: Export on Tasks.",
        "operationId": "StartTaskCsvExport",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "savedFilter",
            "in": "query",
            "description": "Code of a saved filter to apply. Query parameters override the saved filter's values.",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "client",
            "in": "query",
            "description": "Filter by client code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CLI-001\", \"CLI-002\" ]"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "Filter by user code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "recurringTask",
            "in": "query",
            "description": "Filter by recurring task code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"REC-001\", \"REC-002\" ]"
            }
          },
          {
            "name": "service",
            "in": "query",
            "description": "Filter by billable service code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001\", \"SRV-002\" ]"
            }
          },
          {
            "name": "serviceStage",
            "in": "query",
            "description": "Filter by billable service stage - composite \"serviceCode:stageCode\" values, can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"SRV-001:STG-001\", \"SRV-002:STG-003\" ]"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Filter by task category code(s) - can specify multiple. \"__none__\" matches tasks with no category, alone or alongside codes.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"CAT-001\", \"__none__\" ]"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Filter by team code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"payroll-team\" ]"
            }
          },
          {
            "name": "clientManager",
            "in": "query",
            "description": "Filter by the primary client's manager (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "clientPartner",
            "in": "query",
            "description": "Filter by the primary client's partner (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-002\" ]"
            }
          },
          {
            "name": "clientAssociate",
            "in": "query",
            "description": "Filter by the primary client's associate (user codes) - can specify multiple. Clientless tasks are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-003\" ]"
            }
          },
          {
            "name": "servicePreparer",
            "in": "query",
            "description": "Filter by the Preparer on the task's service (user codes) - can specify multiple. The client's own Preparer, else the service's default. Tasks without a Preparer are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-001\" ]"
            }
          },
          {
            "name": "serviceReviewer",
            "in": "query",
            "description": "Filter by the Reviewer on the task's service (user codes) - can specify multiple. The client's own Reviewer, else the service's default. Tasks without a Reviewer are excluded.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"USR-002\" ]"
            }
          },
          {
            "name": "workflow",
            "in": "query",
            "description": "Filter by workflow code(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"WFL-001\", \"WFL-002\" ]"
            }
          },
          {
            "name": "stepType",
            "in": "query",
            "description": "Filter by workflow step type(s) - matches tasks with at least one step of these types",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "Standard",
                  "SendEmail",
                  "DocumentRequest",
                  "DocumentApproval",
                  "ClientConfirmation",
                  "SendDataForm",
                  "SetServiceStage",
                  "UpdateClientData",
                  "SetPipelineStage",
                  "DocumentUpload",
                  "ReviewLoggedTime",
                  "BillForWork",
                  "CisCollectPayments",
                  "CisConfirmReturn",
                  "CisSubmitReturn",
                  "CisVerifySubcontractors",
                  "CisFileNilReturn",
                  "CisRemindPayments",
                  "SendTextMessage"
                ],
                "type": "string"
              },
              "example": "[ \"DocumentRequest\", \"ClientConfirmation\" ]"
            }
          },
          {
            "name": "currentStep",
            "in": "query",
            "description": "Filter by current workflow step name(s) - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"Prepare accounts\" ]"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by task status(es)",
            "schema": {
              "type": "array",
              "items": {
                "enum": [
                  "NotStarted",
                  "InProgress",
                  "Blocked",
                  "Completed",
                  "Skipped"
                ],
                "type": "string"
              },
              "example": "[ \"InProgress\", \"Blocked\" ]"
            }
          },
          {
            "name": "includeWorkflowSteps",
            "in": "query",
            "description": "Include workflow steps in the results (default: false). When true, uses Agenda mode.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range. If CustomDateRange, startDate and endDate are required.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Filter tasks starting from this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Filter tasks ending on this date. Only valid when dateRange=CustomDateRange",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeProjected",
            "in": "query",
            "description": "Include projected (virtual) tasks in the results (default: false)",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "projectUntil",
            "in": "query",
            "description": "Projection horizon for a query with no date range. Requires includeProjected=true and no date range; projects from today to this date while the materialised query stays unbounded.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateBasis",
            "in": "query",
            "description": "Which date field to use as the basis for filtering: StartDate (default) or DueDate",
            "schema": {
              "enum": [
                "Any",
                "StartDate",
                "DueDate",
                "StatutoryDate",
                "CompletedDate"
              ],
              "type": "string"
            }
          },
          {
            "name": "isOverdue",
            "in": "query",
            "description": "Filter to only include overdue tasks (DueDate < today). No date range required when true.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "isUnassigned",
            "in": "query",
            "description": "Include unassigned tasks. Can be combined with user filter to show unassigned OR assigned to specific users.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "isAutomationDisabled",
            "in": "query",
            "description": "True returns only tasks with automation switched off; false only those with it on. Task previews are excluded either way.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across task name, task code and primary client name (minimum 3 characters). Projected tasks are excluded when set.",
            "schema": {
              "type": "string",
              "example": "vat return"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvExportJobDto"
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvExportJobDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/export/csv/{code}": {
      "get": {
        "tags": [
          "Tasks - CSV Export"
        ],
        "summary": "Get Tasks Export Status",
        "description": "Returns the status and progress of a tasks CSV export. When status is 'Completed', downloadUrl holds a time-limited link to the CSV file.\n\nRequires: Export on Tasks.",
        "operationId": "GetTaskCsvExportStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CsvExportJobDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-focus-config": {
      "get": {
        "tags": [
          "Tasks - Focus Config"
        ],
        "summary": "Get Task Focus Config",
        "description": "Gets the current user's task focus panel configuration. Auto-creates an empty default if none exists.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetTaskFocusConfig",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskFocusConfigDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks - Focus Config"
        ],
        "summary": "Upsert Task Focus Config",
        "description": "Creates or updates the current user's task focus panel configuration. Validates that all referenced saved task filters belong to the current user.\n\nRequires: ViewAll on Tasks.",
        "operationId": "UpsertTaskFocusConfig",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTaskFocusConfigRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskFocusConfigDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/import/csv/analyze": {
      "post": {
        "tags": [
          "Tasks - Import"
        ],
        "summary": "Analyze Tasks CSV",
        "description": "Parses a native-format task CSV and returns preview rows for review, with client/user/team/category names resolved and unmatched values flagged. Stateless: no data is persisted. A BrightManager export is rejected with a validation error indicating it needs to be converted first.\n\nRequires: Import on Tasks.",
        "operationId": "AnalyzeTaskCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskImportRowDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/import/csv": {
      "post": {
        "tags": [
          "Tasks - Import"
        ],
        "summary": "Import Tasks CSV",
        "description": "Re-uploads an analyzed task CSV with the user's selections and creates or updates tasks; a row's Notes text becomes a task note. Returns per-row results.\n\nRequires: Import on Tasks.",
        "operationId": "ImportTaskCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file",
                  "selections"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "selections": {
                    "type": "string"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                },
                "selections": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskImportResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/import/csv/convert/analyze": {
      "post": {
        "tags": [
          "Tasks - Import"
        ],
        "summary": "Analyze Tasks CSV Conversion",
        "description": "Analyses a foreign task export (currently BrightManager, saved as CSV) and returns the distinct assignees and progress values needing mapping, with suggested users/statuses, plus a client name match summary. Stateless: no data is persisted.\n\nRequires: Import on Tasks.",
        "operationId": "AnalyzeTaskCsvConversion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskCsvConversionAnalysisDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/tasks/import/csv/convert": {
      "post": {
        "tags": [
          "Tasks - Import"
        ],
        "summary": "Convert Tasks CSV",
        "description": "Converts a BrightManager task export into the native task CSV format using the provided assignee and progress mappings. Every non-empty source field without a native column is preserved in the Notes cell. Returns the converted CSV for download; import it via the native import.\n\nRequires: Import on Tasks.",
        "operationId": "ConvertTaskCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file",
                  "mappings"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "mappings": {
                    "type": "string"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                },
                "mappings": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/projected-tasks/{code}": {
      "get": {
        "tags": [
          "Tasks - Projected"
        ],
        "summary": "Get a single projected task item by composite code",
        "description": "Gets a projected (virtual) task item by its composite code. The code format is: proj-{recurringTaskCode}-{clientCode}-{yyyyMMdd}. Returns 410 Gone with the real task's code when the occurrence has already been created as a task.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetProjectedTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskItemDto"
                }
              }
            }
          },
          "410": {
            "description": "Gone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MaterialisedProjectedTaskDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/projected-tasks": {
      "post": {
        "tags": [
          "Tasks - Projected"
        ],
        "summary": "Materialise a projected task item into the database",
        "description": "Creates a real task item in the database from a projected (virtual) task item\n\nRequires: Create on Tasks.",
        "operationId": "MaterialiseProjectedTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MaterialiseProjectedTaskRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/projected-tasks/{code}/workflow/groups": {
      "get": {
        "tags": [
          "Tasks - Projected"
        ],
        "summary": "Get workflow groups and steps for a projected task with resolved assignments",
        "description": "Retrieves workflow groups and steps for a projected task with resolved assignments and calculated deadlines. No database writes are performed.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetProjectedTaskWorkflowGroups",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkflowGroupProgressDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks": {
      "get": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "List RecurringTaskItems",
        "description": "Lists all RecurringTaskItems for the given tenant.\n\nRequires: ViewAll on RecurringTasks.",
        "operationId": "ListRecurringTaskItems",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/RecurringTaskItemSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "isActive",
            "in": "query",
            "description": "Filter by active status (true = active only, false = inactive only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Filter by billable service code: tasks that run for the service's clients, and tasks assigned to its manager, preparer or reviewer (IsForServiceClients says which)",
            "schema": {
              "type": "string",
              "example": "ACC-001"
            }
          },
          {
            "name": "pipelineCode",
            "in": "query",
            "description": "Filter by sales pipeline code",
            "schema": {
              "type": "string",
              "example": "PIP-001"
            }
          },
          {
            "name": "categoryCode",
            "in": "query",
            "description": "Filter by task category code",
            "schema": {
              "type": "string",
              "example": "CAT-001"
            }
          },
          {
            "name": "workflowCode",
            "in": "query",
            "description": "Filter by workflow code",
            "schema": {
              "type": "string",
              "example": "WF-001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across recurring task code, name, and description (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "vat"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskItemDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Create RecurringTaskItem",
        "description": "Creates a new RecurringTaskItem for the specified tenant.\n\nRequires: Create on RecurringTasks.",
        "operationId": "CreateRecurringTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRecurringTaskItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/{code}": {
      "get": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Get RecurringTaskItem",
        "description": "Gets a RecurringTaskItem for the specified tenant.\n\nRequires: ViewAll on RecurringTasks.",
        "operationId": "GetRecurringTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskItemDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Update RecurringTaskItem",
        "description": "Updates a RecurringTaskItem for the specified tenant.\n\nRequires: Update on RecurringTasks.",
        "operationId": "UpdateRecurringTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRecurringTaskItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Delete RecurringTaskItem",
        "description": "Deletes a RecurringTaskItem for the specified tenant.\n\nRequires: Delete on RecurringTasks.",
        "operationId": "DeleteRecurringTaskItem",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/{code}/library-version": {
      "put": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Revert RecurringTaskItem to Library",
        "description": "Reverts the RecurringTaskItem to the current library template version, overwriting any local edits. The RecurringTaskItem's code is preserved so it remains addressable at the same URL. Returns 400 if the RecurringTaskItem was not imported from the library, or 404 if the RecurringTaskItem or its source library template no longer exists.\n\nRequires: Update on RecurringTasks.",
        "operationId": "RevertRecurringTaskItemToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskItemDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/{code}/resolved-clients": {
      "get": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Get Recurring Task Resolved Clients",
        "description": "Returns a paged list of the clients that are candidates for one of this task's schedules - the population the task applies to, resolved for whichever association type the task uses (so a Clients with Services task yields only holders of those services, and inactive clients are never included). This is the pool the schedule client picker offers, NOT a schedule's membership - that comes back with the schedule itself. Search matches client name or code.\n\nRequires: ViewAll on RecurringTasks.",
        "operationId": "GetRecurringTaskResolvedClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0,
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20,
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodeAndNameDtoPagedResult"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/schedule-preview": {
      "post": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Preview Recurring Task Schedule",
        "description": "Works out the next dates a schedule would produce, without saving anything, so an editor can show them as the schedule changes. A schedule that is not complete yet returns no occurrences, and one that uses a client date returns variesByClient, because its dates differ from client to client.\n\nRequires: ViewAll on RecurringTasks.",
        "operationId": "PreviewRecurringTaskSchedule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveRecurringTaskScheduleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskSchedulePreviewDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/{code}/occurrences": {
      "get": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "List Recurring Task Occurrences",
        "description": "Returns, in date order, one page of this recurring task's occurrences for one client whose occurrence date falls in the window: occurrences still to be created (with the projected task that will open the planned task), tasks already created from it (with their current status), and occurrences that were deleted - either a created task that was deleted, or a planned occurrence cancelled before creation - with who deleted it and when. Omit clientCode for a task that runs without a client. Pass a preset dateRange, or CustomDateRange with startDate and endDate (at most five years). Pass status to show only Projected (shown as Planned), Created or Deleted occurrences. Standard offset/limit paging. A deleted occurrence has no task, so it carries the projected code alone - that is what the restore endpoint takes. An occurrence that was deleted and later restored is live again and reports who deleted it and who brought it back.\n\nRequires: ViewAll on RecurringTasks.",
        "operationId": "ListRecurringTaskOccurrences",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "startDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 100
          },
          {
            "name": "endDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 101
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/RecurringTaskOccurrenceStatus"
            },
            "x-order": 200
          },
          {
            "name": "clientCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "dateRange",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/PresetDateRange"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskOccurrenceDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/{code}/clients": {
      "get": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Get Recurring Task Clients",
        "description": "Gets the list of clients associated with a specific recurring task.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetRecurringTaskClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientRefDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Update Recurring Task Clients",
        "description": "Updates the list of clients associated with a specific recurring task.\n\nRequires: Update on Tasks.",
        "operationId": "UpdateRecurringTaskClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/{code}/services": {
      "get": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Get Recurring Task Services",
        "description": "Gets the list of billable services associated with a specific recurring task.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetRecurringTaskServices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CodeAndNameDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Update Recurring Task Services",
        "description": "Updates the list of billable services associated with a specific recurring task.\n\nRequires: Update on Tasks.",
        "operationId": "UpdateRecurringTaskServices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/{code}/pipelines": {
      "get": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Get Recurring Task Pipelines",
        "description": "Gets the list of pipelines associated with a specific recurring task.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetRecurringTaskPipelines",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CodeAndNameDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Update Recurring Task Pipelines",
        "description": "Updates the list of pipelines associated with a specific recurring task.\n\nRequires: Update on Tasks.",
        "operationId": "UpdateRecurringTaskPipelines",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/{taskCode}/schedules": {
      "get": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "List Recurring Task Schedules",
        "description": "Returns a paged list of a recurring task's schedules, the default schedule pinned first, each with its client count and first few clients. Search matches the schedule name or a linked client's name or code, and keeps every schedule containing a match.\n\nRequires: ViewAll on RecurringTasks.",
        "operationId": "ListRecurringTaskSchedules",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/RecurringTaskScheduleSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskScheduleDtoPagedResult"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Create Recurring Task Schedule",
        "description": "Creates a custom schedule on a recurring task, with or without clients. The schedule must be complete - linked clients' occurrences are generated from it instead of the default schedule. A listed client already on another schedule for this task is moved onto this one.\n\nRequires: Update on RecurringTasks.",
        "operationId": "CreateRecurringTaskSchedule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveRecurringTaskScheduleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskScheduleDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/recurring-tasks/{taskCode}/schedules/{code}": {
      "get": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Get Recurring Task Schedule",
        "description": "Gets one schedule with its full client membership.\n\nRequires: ViewAll on RecurringTasks.",
        "operationId": "GetRecurringTaskSchedule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskScheduleDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Update Recurring Task Schedule",
        "description": "Full replace of a schedule: values and membership. Clients removed from the list revert to the default schedule. Editing the default schedule changes the dates every unlinked client runs on; its membership list must stay empty.\n\nRequires: Update on RecurringTasks.",
        "operationId": "UpdateRecurringTaskSchedule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveRecurringTaskScheduleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringTaskScheduleDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Tasks - Recurring"
        ],
        "summary": "Delete Recurring Task Schedule",
        "description": "Removes a custom schedule, returning every linked client to the recurring task's default schedule. The default schedule cannot be deleted.\n\nRequires: Delete on RecurringTasks.",
        "operationId": "DeleteRecurringTaskSchedule",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "taskCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "RecurringTasks",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/saved-task-filters": {
      "get": {
        "tags": [
          "Tasks - Saved Filters"
        ],
        "summary": "List SavedTaskFilters",
        "description": "Lists the saved task filters visible to the current user within the tenant: their own filters plus any shared with the practice.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListSavedTaskFilters",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/SavedTaskFilterSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "menuOnly",
            "in": "query",
            "description": "Filter to only show filters marked for menu display",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedTaskFilterDtoPagedResult"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Tasks - Saved Filters"
        ],
        "summary": "Create SavedTaskFilter",
        "description": "Creates a new saved task filter owned by the current user.\n\nRequires: ViewAll on Tasks.",
        "operationId": "CreateSavedTaskFilter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSavedTaskFilterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedTaskFilterDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/saved-task-filters/{code}": {
      "get": {
        "tags": [
          "Tasks - Saved Filters"
        ],
        "summary": "Get SavedTaskFilter",
        "description": "Gets a specific saved task filter by code. Only filters owned by or shared with the current user are accessible.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetSavedTaskFilter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedTaskFilterDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks - Saved Filters"
        ],
        "summary": "Update SavedTaskFilter",
        "description": "Updates an existing saved task filter. Only the owner can update a filter.\n\nRequires: ViewAll on Tasks.",
        "operationId": "UpdateSavedTaskFilter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSavedTaskFilterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedTaskFilterDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "delete": {
        "tags": [
          "Tasks - Saved Filters"
        ],
        "summary": "Delete SavedTaskFilter",
        "description": "Deletes a saved task filter. Only the owner can delete a filter.\n\nRequires: ViewAll on Tasks.",
        "operationId": "DeleteSavedTaskFilter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/saved-task-filters/menu-order": {
      "put": {
        "tags": [
          "Tasks - Saved Filters"
        ],
        "summary": "Set Menu Order",
        "description": "Sets the order of the current user's saved task view menu entries. Codes must be supplied in display order. This is a per-user preference and does not affect other users.\n\nRequires: ViewAll on Tasks.",
        "operationId": "SetSavedTaskFilterMenuOrder",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetSavedFilterMenuOrderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/saved-task-filters/{code}/menu": {
      "put": {
        "tags": [
          "Tasks - Saved Filters"
        ],
        "summary": "Set Menu Preference",
        "description": "Sets whether this saved task filter appears in the current user's menu. This is a per-user preference and does not affect other users.\n\nRequires: ViewAll on Tasks.",
        "operationId": "SetSavedTaskFilterMenuPreference",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetSavedFilterMenuRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-settings": {
      "get": {
        "tags": [
          "Tasks - Settings"
        ],
        "summary": "Get task settings",
        "description": "Returns the practice-wide task settings for the specified tenant\n\nOpen to any signed-in user of the tenant: Practice-wide settings that shape how every user's tasks display, readable by every user in the practice",
        "operationId": "GetTaskSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskSettingsDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Practice-wide settings that shape how every user's tasks display, readable by every user in the practice"
      },
      "put": {
        "tags": [
          "Tasks - Settings"
        ],
        "summary": "Update task settings",
        "description": "Updates the practice-wide task settings for the specified tenant\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateTaskSettings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTaskSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-templates": {
      "get": {
        "tags": [
          "Tasks - Templates"
        ],
        "summary": "List TaskTemplates",
        "description": "Lists all TaskTemplates for the given tenant.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListTaskTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TaskTemplateSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Filter by associated billable service code",
            "schema": {
              "type": "string",
              "example": "vat-returns"
            }
          },
          {
            "name": "isActive",
            "in": "query",
            "description": "Filter by active status (true = active only, false = inactive only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "workflowCode",
            "in": "query",
            "description": "Filter by workflow code",
            "schema": {
              "type": "string",
              "example": "WF-001"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across template code, name, and description (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "address"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskTemplateDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Tasks - Templates"
        ],
        "summary": "Create TaskTemplate",
        "description": "Creates a new TaskTemplate for the specified tenant.\n\nRequires: Create on Tasks.",
        "operationId": "CreateTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTaskTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-templates/{code}": {
      "get": {
        "tags": [
          "Tasks - Templates"
        ],
        "summary": "Get TaskTemplate",
        "description": "Gets a TaskTemplate for the specified tenant.\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskTemplateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Tasks - Templates"
        ],
        "summary": "Update TaskTemplate",
        "description": "Updates a TaskTemplate for the specified tenant.\n\nRequires: Update on Tasks.",
        "operationId": "UpdateTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTaskTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Tasks - Templates"
        ],
        "summary": "Delete TaskTemplate",
        "description": "Deletes a TaskTemplate for the specified tenant.\n\nRequires: Delete on Tasks.",
        "operationId": "DeleteTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-templates/library": {
      "get": {
        "tags": [
          "Tasks - Templates"
        ],
        "summary": "List Library TaskTemplates",
        "description": "List all TaskTemplates available in the library as templates. Use optional 'search' query parameter to filter by Code, Name, or Description.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListLibraryTaskTemplates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskTemplateDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-templates/library/{code}": {
      "get": {
        "tags": [
          "Tasks - Templates"
        ],
        "summary": "Get Library TaskTemplate",
        "description": "Get details of a specific TaskTemplate template from the library\n\nRequires: ViewAll on Tasks.",
        "operationId": "GetLibraryTaskTemplate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskTemplateDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-templates/{code}/library-version": {
      "put": {
        "tags": [
          "Tasks - Templates"
        ],
        "summary": "Revert TaskTemplate to Library",
        "description": "Reverts the TaskTemplate to the current library template version, overwriting any local edits. The TaskTemplate's code is preserved so it remains addressable at the same URL. Returns 400 if the TaskTemplate was not imported from the library, or 404 if the TaskTemplate or its source library template no longer exists.\n\nRequires: Update on Tasks.",
        "operationId": "RevertTaskTemplateToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskTemplateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/task-templates/library/import": {
      "post": {
        "tags": [
          "Tasks - Templates"
        ],
        "summary": "Import Task Templates from Library",
        "description": "Imports one or more one-off task templates from the library, cascading their referenced workflows and categories into the tenant.\n\nRequires: Create on Tasks.",
        "operationId": "ImportTaskTemplatesFromLibrary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportTaskTemplatesFromLibraryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskTemplateDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants": {
      "post": {
        "tags": [
          "Tenants"
        ],
        "summary": "Create Tenant",
        "description": "Creates a new tenant and assigns the current user as the admin for that tenant.",
        "operationId": "createTenant",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenantCreateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Tenants"
        ],
        "summary": "List Tenants",
        "description": "Returns a list of all tenants that the authenticated user is a member of.\n\nOpen to any signed-in user of the tenant: Lists the caller's own tenants; no tenant is chosen yet, so there is no role to check",
        "operationId": "listTenants",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TenantDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Lists the caller's own tenants; no tenant is chosen yet, so there is no role to check"
      }
    },
    "/tenants/{code}/me": {
      "get": {
        "tags": [
          "Tenants"
        ],
        "summary": "Get Role",
        "description": "Returns the current users role within the Tenant, including permissions.\n\nOpen to any signed-in user of the tenant: The caller's own role and permissions in this tenant",
        "operationId": "getRoleInTenant",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantUserDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own role and permissions in this tenant"
      }
    },
    "/tenants/{code}": {
      "get": {
        "tags": [
          "Tenants"
        ],
        "summary": "Get Tenant",
        "description": "Retrieves the details of a tenant using its Code identifier.\n\nOpen to any signed-in user of the tenant: Basic details of the tenant the caller belongs to, which the app loads on start; client counts are withheld unless the caller can view clients",
        "operationId": "getTenantByCode",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Basic details of the tenant the caller belongs to, which the app loads on start; client counts are withheld unless the caller can view clients"
      },
      "put": {
        "tags": [
          "Tenants"
        ],
        "summary": "Update Tenant",
        "description": "Updates the details of a tenant identified by its code.\n\nRequires: Update on Settings.",
        "operationId": "updateTenantByCode",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenantUpdateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Settings",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts": {
      "get": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "List Text Broadcasts",
        "description": "Returns a paged list of the practice's bulk texts, newest first. Filter by status. The list over bulk emails and bulk texts together is GET /tenants/{tenant}/broadcasts.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "ListTextBroadcasts",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TextBroadcastSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by status (Draft, Queued, Sending, Completed, Failed, Cancelled, Scheduled, Paused)",
            "schema": {
              "enum": [
                "Draft",
                "Queued",
                "Sending",
                "Completed",
                "Failed",
                "Cancelled",
                "Scheduled",
                "Paused"
              ],
              "type": "string",
              "example": "Draft"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastDtoPagedResult"
                }
              }
            }
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Create Text Broadcast",
        "description": "Creates a draft bulk text. The SMS text is a practice text template or inline text with Liquid tokens, not both. Who is texted at each client is chosen by contact type, on their mobiles. Clients are chosen as for a bulk email: a saved view or a client filter, plus additions and exclusions. Only SMS-only routing is accepted for now. Needs the practice's messaging set up (409 messaging_not_set_up otherwise).\n\nRequires: Create on EmailBroadcasts and Create on Messaging.",
        "operationId": "CreateTextBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTextBroadcastRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Create"
          },
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/audience-summary": {
      "post": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Summarise Text Broadcast Audience",
        "description": "Evaluates a client selection before a draft exists and returns how many clients it resolves to and how many of them do not allow texts; given contact types, also the numbers that would be texted, the clients with no usable mobile and the numbers on the do-not-text list. Read-only.\n\nRequires: Create on EmailBroadcasts.",
        "operationId": "GetTextBroadcastAudienceSummary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TextBroadcastAudienceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastAudienceSummaryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/{code}": {
      "get": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Get Text Broadcast",
        "description": "Returns a single bulk text including its status and progress counters.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "GetTextBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Update Text Broadcast",
        "description": "Updates a draft bulk text (full replacement). Once sent or scheduled it cannot be changed.\n\nRequires: Update on EmailBroadcasts.",
        "operationId": "UpdateTextBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTextBroadcastRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Delete Text Broadcast",
        "description": "Deletes a draft bulk text. A sent one cannot be deleted: it is the record of who was texted.\n\nRequires: Delete on EmailBroadcasts.",
        "operationId": "DeleteTextBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/{code}/recipients": {
      "get": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "List Text Broadcast Recipients",
        "description": "Returns the paged recipient rows, optionally filtered by client name via the search parameter: one per number to text and one per person missed with the reason (no contact of the type, no mobile, not a valid number, contact preference, the do-not-text list, a number already texted with another client). For a draft they are resolved live; once sent, the stored snapshot with each number's delivery status is returned.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "GetTextBroadcastRecipients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TextBroadcastRecipientSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastRecipientDtoPagedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/{code}/repeated-numbers": {
      "get": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "List Repeated Text Broadcast Numbers",
        "description": "For a draft, lists the numbers held by contacts at more than one selected client, how many texts texting each number once would drop, and whether the text is personalised per client.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "GetTextBroadcastRepeatedNumbers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastRepeatedNumbersDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/{code}/preview/{clientCode}": {
      "get": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Preview Text Broadcast",
        "description": "Renders what the bulk text sends the client identified by clientCode: each recipient with the channel, the text and its SMS segments, and each person missed with the reason.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "PreviewTextBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "clientCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 213
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/{code}/estimate": {
      "get": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Estimate Text Broadcast",
        "description": "For a draft, renders every recipient's text and counts its SMS segments as the Messaging Service charges them, at the practice's credits per segment, beside its balance; and says whether now is inside the practice's quiet hours.\n\nRequires: ViewAll on EmailBroadcasts.",
        "operationId": "GetTextBroadcastEstimate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastEstimateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/{code}/send": {
      "post": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Send Text Broadcast",
        "description": "Sends a draft bulk text: resolves its recipients again, saves them as the snapshot (the record of who was texted), marks it Queued and texts them in the background, whatever the practice's quiet hours. Refused with 409 messaging_no_credit when the practice's balance is under what it would cost. Poll the bulk text for progress and the recipients route for each number's status. When the optional body sets scheduledAt, it is not sent now: it moves to Scheduled and is sent then; a time inside the practice's quiet hours is refused (400).\n\nRequires: Create on EmailBroadcasts and Create on Messaging.",
        "operationId": "SendTextBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendTextBroadcastRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Create"
          },
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/{code}/resume": {
      "post": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Resume Text Broadcast",
        "description": "Carries on a paused bulk text: the numbers still Pending are texted, each with the request id it was given when sent, so nobody is texted twice. Refused with 409 messaging_no_credit when the balance is under what the rest would cost.\n\nRequires: Create on EmailBroadcasts and Create on Messaging.",
        "operationId": "ResumeTextBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Create"
          },
          {
            "entity": "Messaging",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/{code}/revert-to-draft": {
      "post": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Revert Text Broadcast to Draft",
        "description": "Reverts a scheduled bulk text to Draft by cancelling its pending scheduled send, so it can be edited again. It is not sent until it is sent or scheduled again.\n\nRequires: Update on EmailBroadcasts.",
        "operationId": "RevertTextBroadcastToDraft",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/text-broadcasts/{code}/cancel": {
      "post": {
        "tags": [
          "Text Broadcasts"
        ],
        "summary": "Cancel Text Broadcast",
        "description": "Cancels a queued, sending or paused bulk text. The numbers not yet texted stay Pending and are not sent.\n\nRequires: Update on EmailBroadcasts.",
        "operationId": "CancelTextBroadcast",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextBroadcastDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "409": {
            "description": "Conflict"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "EmailBroadcasts",
            "permission": "Update"
          }
        ]
      }
    },
    "/oauth/third-party/callback": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "OAuth Callback",
        "description": "Handles OAuth redirect with authorization code to exchange for tokens",
        "operationId": "ThirdPartyOAuthRedirect",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "error",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "error_description",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "location",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "realmId",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "state",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/tenants/{tenant}/connections": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "List ThirdPartyConnections",
        "description": "Lists all ThirdPartyConnections for the given tenant.\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "ListThirdPartyConnections",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/ThirdPartyConnectionSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "capability",
            "in": "query",
            "description": "Filter by platform capability (e.g. DocumentManagement, Accounting)",
            "schema": {
              "enum": [
                "None",
                "Accounting",
                "CRM",
                "DocumentManagement",
                "Communication",
                "ProjectManagement",
                "TimeTracking",
                "Payments",
                "ClientImport",
                "DirectDebit",
                "AML",
                "Proposals",
                "BookkeepingHealth",
                "ESignature",
                "MeetingNotes",
                "ClientSync"
              ],
              "type": "string",
              "example": "DocumentManagement"
            }
          },
          {
            "name": "platform",
            "in": "query",
            "description": "Filter by platform identifier (e.g. Xero, QuickBooks)",
            "schema": {
              "type": "string",
              "example": "Xero"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThirdPartyConnectionDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Create ThirdPartyConnection",
        "description": "Creates a new ThirdPartyConnection for the specified tenant.\n\nRequires: Create on ThirdPartyConnections.",
        "operationId": "CreateThirdPartyConnection",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateThirdPartyConnectionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThirdPartyConnectionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Get ThirdPartyConnection",
        "description": "Gets a ThirdPartyConnection for the specified tenant.\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "GetThirdPartyConnection",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThirdPartyConnectionDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Update ThirdPartyConnection",
        "description": "Updates a ThirdPartyConnection for the specified tenant.\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "UpdateThirdPartyConnection",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateThirdPartyConnectionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThirdPartyConnectionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Delete Third-Party Connection",
        "description": "Disconnects the connection: its credentials are cleared and it leaves the tenant's slot, but the connection and everything attached to it stay, so reconnecting continues it. Pass permanent=true to remove the connection outright, for document storage connections and for any connection that is not connected: its documents are detached and its client folder mappings are deleted. For storage that is the deliberate way to move to a different account or provider. Either form is refused while the connection is still the tenant's active one.\n\nRequires: Delete on ThirdPartyConnections.",
        "operationId": "DeleteThirdPartyConnection",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "permanent",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/set-organization": {
      "post": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Set Organization",
        "description": "If the ThirdPartyConnection has a status of \"Initialising\", then you need to use this endpoint to set the organization Id. The status will then become \"Active\"\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "SetOrganization",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetOrganizationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/webhook-setup": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Get Meeting Notes Webhook Setup",
        "description": "For a note taker whose webhook can only be set up by hand on its own site (Fireflies, Circleback): the address to paste in, the signing secret when Sodium makes it (or whether Sodium holds the one the note taker made), and when the last delivery arrived. A 400 on any other platform.\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "GetMeetingNotesWebhookSetup",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeetingNotesWebhookSetupDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/webhook-secret": {
      "put": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Set Meeting Notes Webhook Secret",
        "description": "For a note taker that makes the signing secret for a webhook set up by hand on its own site (Circleback): stores the secret the practice pasted in, so deliveries can be checked. Blank clears it, after which every delivery is refused. Returns the webhook setup. A 400 on any other platform.\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "SetMeetingNotesWebhookSecret",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MeetingNotesWebhookSecretRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeetingNotesWebhookSetupDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/options": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Get Connection Options",
        "description": "What the connection is set to: what the practice chose, else the platform's defaults. An option the platform does not offer is null.\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "GetConnectionOptions",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionOptionsDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Set Connection Options",
        "description": "Changes what the connection is set to. An option left out keeps its value. A 400 on a platform with no options.\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "SetConnectionOptions",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectionOptionsDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionOptionsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/lookup": {
      "post": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Look Up Meeting Notes",
        "description": "Meeting notes connections only. Queues a look-up of every note created since the connection's import-from date that Sodium does not hold yet, imported or ignored, and returns at once. Catches up on anything the platform has not sent yet, or the daily sweep has not reached.\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "LookUpMeetingNotes",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/client-sync": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Get Client List Sync",
        "description": "Whether the connection's client list is kept in step with Sodium's, when it was last polled and why the last poll failed. Answers for a connection that has lapsed. A 400 for a connection that does not offer the sync.\n\nRequires: Update on Clients.",
        "operationId": "GetClientListSync",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientListSyncDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/client-sync/preview": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Preview Client List Sync",
        "description": "What switching the client list sync on would do, for its confirm step: how many of the platform's active clients not linked to a Sodium client it would add to Sodium, and how many active Sodium clients not linked on the platform it would add there. Reads the platform's whole client list. A 400 for a connection that does not offer the sync, is not connected, or cannot add clients.\n\nRequires: Update on Clients.",
        "operationId": "PreviewClientListSync",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientListSyncPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/client-sync/enable": {
      "post": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Enable Client List Sync",
        "description": "Switches the client list sync on and queues its first full pass, which adds the unlinked active clients each way and pairs the contacts of the linked ones; link the clients that exist in both first, on the import page. The sync acts as the caller from then on. Returns at once. A 400 for a connection that does not offer the sync, is not connected, or cannot add clients.\n\nRequires: Update on Clients.",
        "operationId": "EnableClientListSync",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/client-sync/disable": {
      "post": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Disable Client List Sync",
        "description": "Switches the client list sync off. Links and clients stay as they are. Works on any connection, including one that has lapsed.\n\nRequires: Update on Clients.",
        "operationId": "DisableClientListSync",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Clients",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/reauthorise": {
      "post": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Reauthorise Connection",
        "description": "Reconnects an existing connection in place. On OAuth platforms it starts a fresh sign-in and returns the connection with a new authorisation URL to send the browser to; on API-key platforms pass the fresh key as 'apiKey' and it is validated live onto the same row. Use this for \"Reconnect\" rather than creating a connection: the row keeps its code, so documents, folder mappings, client books links and bookkeeping health links stay attached, and platforms whose refresh token rotates never end up with two rows holding one grant. On document storage platforms creating a connection also continues the existing one, and a different account must still reach the practice's files or the sign-in is refused. To move anyway, remove the connection first, which detaches its documents and client folders.\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "reauthoriseConnection",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReauthoriseConnectionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThirdPartyConnectionDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/base-folder": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Get Base Folder",
        "description": "Gets the base folder reference for a document storage connection, if one has been set.\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "getBaseFolder",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalFolderReferenceDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Set Base Folder",
        "description": "Creates or updates the base folder reference for a document storage connection. The connection must have the DocumentManagement capability.\n\nRequires: Update on ThirdPartyConnections.",
        "operationId": "upsertBaseFolder",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertBaseFolderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalFolderReferenceDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/auth-credentials": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "Get Connection Credentials",
        "description": "Returns a valid access token for a document storage connection so the browser can run the provider's folder picker, refreshing the token if expired. The token works directly against the provider, so it is only given to users who set up storage (create or update connections) or choose a client's folder (update client documents), never to view-only users. The connection must be a document storage connection that uses OAuth authentication.\n\nRequires at least one of: Create on ThirdPartyConnections or Update on ThirdPartyConnections or Update on ClientDocuments.",
        "operationId": "getConnectionCredentials",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionCredentialsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-any-permissions": [
          [
            {
              "entity": "ThirdPartyConnections",
              "permission": "Create"
            },
            {
              "entity": "ThirdPartyConnections",
              "permission": "Update"
            },
            {
              "entity": "ClientDocuments",
              "permission": "Update"
            }
          ]
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/storage-locations": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "List Storage Locations",
        "description": "Lists storage locations (e.g. SharePoint sites and their document libraries) available through this connection. Uses cached data by default; pass `refresh=true` to re-query the platform API.\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "listConnectionStorageLocations",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "refresh",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StorageLocationDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/connections/{code}/folders": {
      "get": {
        "tags": [
          "Third-Party Connections"
        ],
        "summary": "List Connection Folders",
        "description": "Lists subfolders for a document storage connection. Pass `parentFolderId` to drill into a specific folder; omit it to list the connection's root folders.\n\nRequires: ViewAll on ThirdPartyConnections.",
        "operationId": "listConnectionFolders",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "driveId",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "parentFolderId",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ConnectionFolderDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ThirdPartyConnections",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "List TimeEntries",
        "description": "Lists all TimeEntries for the given tenant.\n\nRequires: ViewAll on TimeTracking.",
        "operationId": "ListTimeEntries",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TimeEntrySortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "userCode",
            "in": "query",
            "description": "Filter by team member code",
            "schema": {
              "type": "string",
              "example": "jsmith"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by linked client code",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "taskItemCode",
            "in": "query",
            "description": "Filter by linked task code",
            "schema": {
              "type": "string",
              "example": "task-123"
            }
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Filter by the client billable service the time was logged directly against (not via a task)",
            "schema": {
              "type": "string",
              "example": "cbs-123"
            }
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the entry window. When set (and not CustomDateRange), fromDate/toDate are calculated automatically.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "fromDate",
            "in": "query",
            "description": "Only include entries on or after this date",
            "schema": {
              "type": "string",
              "example": "2026-01-01"
            }
          },
          {
            "name": "toDate",
            "in": "query",
            "description": "Only include entries on or before this date",
            "schema": {
              "type": "string",
              "example": "2026-01-31"
            }
          },
          {
            "name": "isBillable",
            "in": "query",
            "description": "Filter by whether the entry is billable",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "isBilled",
            "in": "query",
            "description": "Filter by whether the entry has been billed",
            "schema": {
              "type": "boolean",
              "example": "false"
            }
          },
          {
            "name": "hasOpenWip",
            "in": "query",
            "description": "Filter by whether the entry still has WIP open (unbilled, or part-settled). True also includes rated-less billable entries; non-billable time never has open WIP.",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "isPaid",
            "in": "query",
            "description": "Filter by whether the entry has been paid to the team member on a pay run",
            "schema": {
              "type": "boolean",
              "example": "false"
            }
          },
          {
            "name": "isPaymentApproved",
            "in": "query",
            "description": "Filter by whether the entry has been approved for payment to the team member",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "payRunCode",
            "in": "query",
            "description": "Filter to the entries paid on one pay run",
            "schema": {
              "type": "string",
              "example": "payrun-123"
            }
          },
          {
            "name": "externalEventUid",
            "in": "query",
            "description": "Filter to the entries logged from one external calendar meeting (its occurrence UID)",
            "schema": {
              "type": "string",
              "example": "abc123@google.com:20261009T140000"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across description, client name and task name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "vat return"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeEntryDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Create TimeEntry",
        "description": "Creates a new TimeEntry for the specified tenant.\n\nRequires: Create on TimeTracking.",
        "operationId": "CreateTimeEntry",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTimeEntryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeEntryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/{code}": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Get TimeEntry",
        "description": "Gets a TimeEntry for the specified tenant.\n\nRequires: ViewAll on TimeTracking.",
        "operationId": "GetTimeEntry",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeEntryDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Update TimeEntry",
        "description": "Updates a TimeEntry for the specified tenant.\n\nRequires: Update on TimeTracking.",
        "operationId": "UpdateTimeEntry",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTimeEntryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeEntryDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Delete TimeEntry",
        "description": "Deletes a TimeEntry for the specified tenant.\n\nRequires: Delete on TimeTracking.",
        "operationId": "DeleteTimeEntry",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/csv": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Export Time Entries",
        "description": "Every individual time entry matching the filters as a CSV download, one row per entry: date, start and end time (UK time), team member and email, client, task, task category, service, description, billable, duration, charge-out rate and value. Takes the same filters as the time entry list. Users restricted to their own time get only their own entries. The cost rate and cost columns are included only for callers with the Cost Rates permission.\n\nRequires: ViewAll on TimeTracking and Export on Reports.",
        "operationId": "ExportTimeEntriesCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "query",
            "description": "Filter by team member code",
            "schema": {
              "type": "string",
              "example": "jsmith"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by linked client code",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "taskItemCode",
            "in": "query",
            "description": "Filter by linked task code",
            "schema": {
              "type": "string",
              "example": "task-123"
            }
          },
          {
            "name": "serviceCode",
            "in": "query",
            "description": "Filter by the client billable service the time was logged directly against (not via a task)",
            "schema": {
              "type": "string",
              "example": "cbs-123"
            }
          },
          {
            "name": "dateRange",
            "in": "query",
            "description": "Preset date range for the entry window. When set (and not CustomDateRange), fromDate/toDate are calculated automatically.",
            "schema": {
              "enum": [
                "ThisWeek",
                "NextWeek",
                "Last7Days",
                "Next7Days",
                "Last30Days",
                "Next30Days",
                "PreviousMonth",
                "ThisMonth",
                "NextMonth",
                "PreviousQuarter",
                "ThisQuarter",
                "NextQuarter",
                "PreviousYear",
                "ThisYear",
                "NextYear",
                "YearToDate",
                "PreviousTaxYear",
                "ThisTaxYear",
                "NextTaxYear",
                "TaxYearToDate",
                "Today",
                "PreviousWeek",
                "TodayOnwards",
                "Last12Months",
                "Last12FullMonths",
                "CustomDateRange"
              ],
              "type": "string"
            }
          },
          {
            "name": "fromDate",
            "in": "query",
            "description": "Only include entries on or after this date",
            "schema": {
              "type": "string",
              "example": "2026-01-01"
            }
          },
          {
            "name": "toDate",
            "in": "query",
            "description": "Only include entries on or before this date",
            "schema": {
              "type": "string",
              "example": "2026-01-31"
            }
          },
          {
            "name": "isBillable",
            "in": "query",
            "description": "Filter by whether the entry is billable",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "isBilled",
            "in": "query",
            "description": "Filter by whether the entry has been billed",
            "schema": {
              "type": "boolean",
              "example": "false"
            }
          },
          {
            "name": "hasOpenWip",
            "in": "query",
            "description": "Filter by whether the entry still has WIP open (unbilled, or part-settled). True also includes rated-less billable entries; non-billable time never has open WIP.",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "isPaid",
            "in": "query",
            "description": "Filter by whether the entry has been paid to the team member on a pay run",
            "schema": {
              "type": "boolean",
              "example": "false"
            }
          },
          {
            "name": "isPaymentApproved",
            "in": "query",
            "description": "Filter by whether the entry has been approved for payment to the team member",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "payRunCode",
            "in": "query",
            "description": "Filter to the entries paid on one pay run",
            "schema": {
              "type": "string",
              "example": "payrun-123"
            }
          },
          {
            "name": "externalEventUid",
            "in": "query",
            "description": "Filter to the entries logged from one external calendar meeting (its occurrence UID)",
            "schema": {
              "type": "string",
              "example": "abc123@google.com:20261009T140000"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across description, client name and task name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "vat return"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          },
          {
            "entity": "Reports",
            "permission": "Export"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/unbilled-clients": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "List Unbilled Time Clients",
        "description": "Lists the clients that have unbilled billable time, with the unbilled minutes, entry count, value, oldest entry date and unrated entry count for each. The date window and team member narrow which entries are counted, so the figures always match the entries behind them. Users restricted to their own time see a rollup of their own entries only. Paged, ordered by client name unless sorted otherwise; search filters on the client name.\n\nRequires: ViewAll on TimeTracking.",
        "operationId": "GetUnbilledTimeClients",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "userCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 212
          },
          {
            "name": "fromDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "toDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0,
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20,
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/UnbilledTimeClientSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "default": false,
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnbilledTimeClientDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/expected-minutes": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Get Expected Time",
        "description": "The minutes a team member's working pattern expects of them on each day of the window (own pattern, falling back to the practice default; bank holidays excluded) - the daily targets behind the Time calendar. Defaults to the calling user; users restricted to their own time can only request themselves. The window is capped at 62 days.\n\nRequires: ViewAll on TimeTracking.",
        "operationId": "GetExpectedTime",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 212
          },
          {
            "name": "fromDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "toDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExpectedTimeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/unpaid-users": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "List Unpaid Time Users",
        "description": "Lists the team members the practice pays for tracked time, with each member's unpaid minutes, entry count, value at the stamped cost rates, approved-for-payment portion, oldest unpaid entry date and uncosted entry count. Current members always get a row; former members only while they still have unpaid time. The date window narrows which entries are counted, so the figures always match the entries behind them. Paged, ordered by name unless sorted otherwise; search filters on the member name.\n\nRequires: ViewAll on TimeTracking and ViewAll on CostRates.",
        "operationId": "GetUnpaidTimeUsers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          },
          {
            "name": "fromDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "toDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0,
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20,
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/UnpaidTimeUserSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "default": false,
              "example": "false"
            },
            "x-order": 503
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnpaidTimeUserDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          },
          {
            "entity": "CostRates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/approve-payment": {
      "post": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Approve Time Payment",
        "description": "Approves (or un-approves) time entries for payment to the team members who logged them. Approval is a stamp, not a lock — editing an approved entry clears the approval. Entries must be unpaid, and approving requires the members to be paid for tracked time.\n\nRequires: Update on TimeTracking and ViewAll on CostRates.",
        "operationId": "ApproveTimePayment",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApproveTimePaymentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Update"
          },
          {
            "entity": "CostRates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/pay": {
      "post": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Pay Time Entries",
        "description": "Pays a batch of one team member's unpaid time entries on a new pay run, at the cost rates stamped on the entries. The member must be paid for tracked time and every entry must carry a cost rate. Entries not yet approved for payment are approved as part of paying them. Paid entries can no longer be edited or deleted; deleting the pay run releases them back to approved.\n\nRequires: Update on TimeTracking and ViewAll on CostRates.",
        "operationId": "PayTimeEntries",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayTimeEntriesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimePayRunDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Update"
          },
          {
            "entity": "CostRates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/pay-runs": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "List Time Pay Runs",
        "description": "Lists the pay runs recorded for tracked time, newest first unless sorted otherwise. Pass userCode to narrow to one team member's payment history.\n\nRequires: ViewAll on TimeTracking and ViewAll on CostRates.",
        "operationId": "ListTimePayRuns",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0,
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20,
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TimePayRunSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "default": true,
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "userCode",
            "in": "query",
            "description": "Filter by the code of the team member who was paid",
            "schema": {
              "type": "string",
              "example": "jsmith"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimePayRunDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          },
          {
            "entity": "CostRates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/pay-runs/{code}": {
      "delete": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Delete Time Pay Run",
        "description": "Deletes a pay run and un-pays its time entries — they keep their payment approval and become available to pay again. Use this to undo a payment recorded by mistake.\n\nRequires: Delete on TimeTracking and ViewAll on CostRates.",
        "operationId": "DeleteTimePayRun",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Delete"
          },
          {
            "entity": "CostRates",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/bill": {
      "post": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Bill Time Entries",
        "description": "Converts billable time entries with open WIP for a single client into billing line items, one per distinct hourly rate or one per entry. With no fee the entries bill at their full billable value. With a fee, the fee is spread across the entries pro rata to their open WIP and the difference is recorded as a write-off (or write-on) with a reason; WIP the fee does not cover is left open or written off per remainderHandling. Explicit per-entry allocations override the pro-rata spread. Users restricted to their own time can only bill their own entries.\n\nRequires: Create on ClientBilling.",
        "operationId": "BillTimeEntries",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillTimeEntriesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientBillingLineItemDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/write-off": {
      "post": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Write Off Time Entries",
        "description": "Disposes of open WIP on time entries with no bill raised, recording one write-off allocation per entry with the given reason. Omit the amount to write off everything still open on each entry; give an amount to spread it pro rata to open WIP (each entry capped at its own); or give explicit per-entry amounts. Written-off entries lock their duration, rate, billability and client.\n\nRequires: Update on ClientBilling.",
        "operationId": "WriteOffTimeEntries",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WriteOffTimeEntriesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TimeEntryAllocationDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/{code}/allocations": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Get Time Entry Allocations",
        "description": "The disposal history of one time entry, oldest first: each billing line it was billed on and each write-off against it, with the WIP settled, the amount billed and the difference.\n\nRequires: ViewAll on TimeTracking.",
        "operationId": "GetTimeEntryAllocations",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TimeEntryAllocationDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/{code}/allocations/{allocationCode}": {
      "delete": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Undo Time Entry Write-off",
        "description": "Deletes a pure write-off allocation (one with no billing line behind it) and hands the WIP back to the entry. A billed allocation is reversed by deleting its billing line item instead.\n\nRequires: Delete on ClientBilling.",
        "operationId": "DeleteTimeEntryAllocation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "allocationCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/bill-clients": {
      "post": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Bill Clients Time",
        "description": "Bills several clients' unbilled billable time in one run, resolving each client's entries from the given date window and team member. Clients are billed independently — a result row is returned for every requested client, carrying its own error when that client failed. Entries with no hourly rate cannot be billed and are counted as skipped rather than failing the client. Users restricted to their own time bill their own entries only.\n\nRequires: Create on ClientBilling.",
        "operationId": "BillClientsTime",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillClientsTimeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BillClientTimeResultDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/resolve-rates": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Resolve Time Entry Rates",
        "description": "The charge-out rate a time entry would get if logged now for the team member (the caller when omitted), date, task and service — the team member's rate for the task category or service, then the practice's, then the team member's own rate, then the practice default. Link a task or a service (with its client), not both.\n\nRequires: Create on TimeTracking.",
        "operationId": "ResolveTimeEntryRates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 212
          },
          {
            "name": "clientCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "clientBillableServiceCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "entryDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 400
          },
          {
            "name": "taskItemCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResolvedTimeEntryRatesDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/stage-options": {
      "get": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Get Time Entry Stage Options",
        "description": "The service stages a time entry can be logged in, for an entry on a task (taskItemCode) or straight on a client's service (clientCode and clientBillableServiceCode), and the stage it defaults to: the stage the task last moved its service to, else the service's current stage. Empty when the service has no stages. 404 for a task or client the caller cannot see.\n\nRequires: Create on TimeTracking.",
        "operationId": "GetTimeEntryStageOptions",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "clientCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 213
          },
          {
            "name": "clientBillableServiceCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "taskItemCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeEntryStageOptionsDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/rate-recalculation/preview": {
      "post": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Preview Rate Recalculation",
        "description": "Lists the unpaid time entries from the date whose stamped rates differ from the rates that apply now, with the current and new rates. Charge-out rates only change on billable entries with nothing billed or written off. Cost rates are only considered (and shown) for callers with the Cost Rates update permission; a changed cost rate clears the entry's payment approval. A rate no rule sets now is left as it is.\n\nRequires: Update on TimeTracking.",
        "operationId": "PreviewTimeEntryRateRecalculation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TimeEntryRateRecalculationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TimeEntryRateChangeDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/rate-recalculation/apply": {
      "post": {
        "tags": [
          "Time Tracking"
        ],
        "summary": "Apply Rate Recalculation",
        "description": "Re-applies the rates that apply now to the chosen entries from a preview, in one transaction. The rates are worked out again on the server, under the same rules as the preview, so an entry paid since the preview, or whose rates already match, is left out, and one billed or written off since keeps its charge-out rate. If one is paid, billed or written off during the write itself, nothing is written and the preview must be run again.\n\nRequires: Update on TimeTracking.",
        "operationId": "ApplyTimeEntryRateRecalculation",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyTimeEntryRateRecalculationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeEntryRateRecalculationResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/import/csv/analyze": {
      "post": {
        "tags": [
          "Time Tracking - Import"
        ],
        "summary": "Analyze Time CSV",
        "description": "Parses a time CSV and returns the rows for review plus the distinct team member and\nclient names in the file, each with a suggested match. Columns are found by name:\nthe file needs a Date column, a Team Member (or User) column and a duration —\nDuration (Minutes), Duration (Hours) (decimal or h:mm), or Start Time and End Time.\nOptional columns: Client, Billable, Description/Notes; Task, Category, Project and\nTags text is folded into the description. Rows identical to an existing entry are\nflagged as duplicates. Stateless: no data is persisted.\n\nRequires: Import on TimeTracking.",
        "operationId": "AnalyzeTimeCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeImportAnalysisDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-entries/import/csv": {
      "post": {
        "tags": [
          "Time Tracking - Import"
        ],
        "summary": "Import Time CSV",
        "description": "Re-uploads an analyzed time CSV with the selected row ids and the team member and\nclient name mappings, and creates a time entry per selected row. Entries go through\nthe standard create path, so charge and cost rates are stamped from the team member's\nrate on the entry date and the practice's link requirement applies. Returns per-row\nresults; call it repeatedly with slices of the row ids to import a large file in batches.\n\nRequires: Import on TimeTracking.",
        "operationId": "ImportTimeCsv",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file",
                  "selections"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "selections": {
                    "type": "string"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                },
                "selections": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeImportResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Import"
          }
        ]
      }
    },
    "/tenants/{tenant}/work-type-rates": {
      "get": {
        "tags": [
          "Time Tracking - Rates"
        ],
        "summary": "List Practice Work Type Rates",
        "description": "Lists the practice's rates by task category or service, grouped by type of work: each one's current entry first, then history by start date descending. Cost rates are null without the Cost Rates permission.\n\nRequires: ViewAll on TimeTracking.",
        "operationId": "ListPracticeWorkTypeRates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkTypeRateDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Time Tracking - Rates"
        ],
        "summary": "Change Practice Work Type Rate",
        "description": "Sets the practice's current rate for a task category or a service. With preserveHistory the current entry is closed the day before effectiveFrom and a new current entry begins; without it the current entry is corrected in place. Rates already stamped on logged time are not changed. Setting a cost rate requires the Cost Rates permission.\n\nRequires: Update on TimeTracking.",
        "operationId": "ChangePracticeWorkTypeRate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeWorkTypeRateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkTypeRateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/work-type-rates/{rateCode}": {
      "delete": {
        "tags": [
          "Time Tracking - Rates"
        ],
        "summary": "Delete Practice Work Type Rate",
        "description": "Deletes one rate entry. Deleting the current entry leaves that type of work with no rate of its own, so the next rule down applies to newly logged time. Deleting an entry that holds a cost rate requires the Cost Rates permission.\n\nRequires: Update on TimeTracking.",
        "operationId": "DeletePracticeWorkTypeRate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "rateCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-recording-settings": {
      "get": {
        "tags": [
          "Time Tracking - Settings"
        ],
        "summary": "Get time recording settings",
        "description": "Returns the time recording settings for the specified tenant\n\nRequires: ViewAll on TimeTracking.",
        "operationId": "GetTimeTracking-Settings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeRecordingSettingsDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Time Tracking - Settings"
        ],
        "summary": "Update time recording settings",
        "description": "Updates the time recording settings for the specified tenant\n\nRequires: Update on TimeTracking.",
        "operationId": "UpdateTimeTracking-Settings",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTimeRecordingSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeRecordingSettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-off": {
      "get": {
        "tags": [
          "Time Tracking - Time Off"
        ],
        "summary": "List Time Off",
        "description": "Time off overlapping the optional window (startDate to endDate, inclusive), latest first. Pass userCode for one member. Without it, everyone's for a caller with Time Off ViewAll, otherwise the caller's own. Asking for someone else's without the permission is a 403.\n\nOpen to any signed-in user of the tenant: Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case",
        "operationId": "ListTimeOff",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "startDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 100
          },
          {
            "name": "endDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 101
          },
          {
            "name": "userCode",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 212
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TimeOffDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case"
      },
      "post": {
        "tags": [
          "Time Tracking - Time Off"
        ],
        "summary": "Create Time Off",
        "description": "Records time off over a date range, for the caller or (with Time Off Create) for tenantUserCode. Leave minutesPerDay empty for whole days. Expected hours drop on each of its days. A member's time off can't overlap, and one record covers at most 366 days.\n\nOpen to any signed-in user of the tenant: Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case",
        "operationId": "CreateTimeOff",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TimeOffRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeOffDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case"
      }
    },
    "/tenants/{tenant}/time-off/away": {
      "get": {
        "tags": [
          "Time Tracking - Time Off"
        ],
        "summary": "List Time Away",
        "description": "Who is away between startDate and endDate (inclusive): each period of time off overlapping the window, with its member and dates only. Never the kind or notes, so it needs only the user list's permission. For flagging people on leave when work dated in the window is assigned.\n\nRequires: ViewAll on Users.",
        "operationId": "ListTimeAway",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "startDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 100
          },
          {
            "name": "endDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "x-order": 101
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TimeAwayDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/time-off/{code}": {
      "get": {
        "tags": [
          "Time Tracking - Time Off"
        ],
        "summary": "Get Time Off",
        "description": "One period of time off. Someone else's is a 404 without Time Off ViewAll.\n\nOpen to any signed-in user of the tenant: Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case",
        "operationId": "GetTimeOff",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeOffDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case"
      },
      "put": {
        "tags": [
          "Time Tracking - Time Off"
        ],
        "summary": "Update Time Off",
        "description": "Full replacement of one period of time off. Changing someone else's needs Time Off Update.\n\nOpen to any signed-in user of the tenant: Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case",
        "operationId": "UpdateTimeOff",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TimeOffRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeOffDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case"
      },
      "delete": {
        "tags": [
          "Time Tracking - Time Off"
        ],
        "summary": "Delete Time Off",
        "description": "Removes one period of time off, putting the member's expected hours back. Removing someone else's needs Time Off Delete.\n\nOpen to any signed-in user of the tenant: Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case",
        "operationId": "DeleteTimeOff",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Your own time off needs no permission; anyone else's needs the Time Off permission, checked in the use case"
      }
    },
    "/tenants/{tenant}/timer": {
      "get": {
        "tags": [
          "Time Tracking - Timer"
        ],
        "summary": "Get Running Timer",
        "description": "Returns the calling user's running timer, or null when no timer is running.\n\nRequires: ViewAll on TimeTracking.",
        "operationId": "GetRunningTimer",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunningTimerDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Time Tracking - Timer"
        ],
        "summary": "Start Running Timer",
        "description": "Starts a timer for the calling user, or updates the details of the one already running. The start time is preserved on update.\n\nRequires: Create on TimeTracking.",
        "operationId": "StartRunningTimer",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartRunningTimerRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunningTimerDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Create"
          }
        ]
      },
      "delete": {
        "tags": [
          "Time Tracking - Timer"
        ],
        "summary": "Discard Running Timer",
        "description": "Discards the calling user's running timer without logging any time.\n\nRequires: Create on TimeTracking.",
        "operationId": "DiscardRunningTimer",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/timer/pause": {
      "post": {
        "tags": [
          "Time Tracking - Timer"
        ],
        "summary": "Pause Running Timer",
        "description": "Pauses the calling user's running timer — elapsed time stops accruing until it is resumed. Pausing an already-paused timer has no effect.\n\nRequires: Create on TimeTracking.",
        "operationId": "PauseRunningTimer",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunningTimerDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/timer/resume": {
      "post": {
        "tags": [
          "Time Tracking - Timer"
        ],
        "summary": "Resume Running Timer",
        "description": "Resumes the calling user's paused timer. Resuming a timer that isn't paused has no effect.\n\nRequires: Create on TimeTracking.",
        "operationId": "ResumeRunningTimer",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunningTimerDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "TimeTracking",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/timers": {
      "get": {
        "tags": [
          "Time Tracking - Timer"
        ],
        "summary": "List Running Timers",
        "description": "Lists every running timer in the tenant, longest-running first — the admin view for spotting forgotten timers.\n\nRequires: ViewAll on Users.",
        "operationId": "ListRunningTimers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RunningTimerDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/timers/{code}/pause": {
      "post": {
        "tags": [
          "Time Tracking - Timer"
        ],
        "summary": "Pause Running Timer By Code",
        "description": "Pauses any user's running timer — stops the clock on a forgotten timer without losing the accrued time. The owner can still resume or log it. Pausing an already-paused timer has no effect.\n\nRequires: Update on Users.",
        "operationId": "PauseRunningTimerByCode",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunningTimerDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/timers/{code}": {
      "delete": {
        "tags": [
          "Time Tracking - Timer"
        ],
        "summary": "Discard Running Timer By Code",
        "description": "Discards any user's running timer without logging time — the admin cleanup action for forgotten timers.\n\nRequires: Update on Users.",
        "operationId": "DiscardRunningTimerByCode",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/working-patterns": {
      "get": {
        "tags": [
          "Time Tracking - Working Patterns"
        ],
        "summary": "List WorkingPatterns",
        "description": "Lists all WorkingPatterns for the given tenant.\n\nRequires: ViewAll on WorkingPatterns.",
        "operationId": "ListWorkingPatterns",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/WorkingPatternSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkingPatternDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "WorkingPatterns",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Time Tracking - Working Patterns"
        ],
        "summary": "Create WorkingPattern",
        "description": "Creates a new WorkingPattern for the specified tenant.\n\nRequires: Create on WorkingPatterns.",
        "operationId": "CreateWorkingPattern",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkingPatternRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkingPatternDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "WorkingPatterns",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/working-patterns/{code}": {
      "get": {
        "tags": [
          "Time Tracking - Working Patterns"
        ],
        "summary": "Get WorkingPattern",
        "description": "Gets a WorkingPattern for the specified tenant.\n\nRequires: ViewAll on WorkingPatterns.",
        "operationId": "GetWorkingPattern",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkingPatternDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "WorkingPatterns",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Time Tracking - Working Patterns"
        ],
        "summary": "Update WorkingPattern",
        "description": "Updates a WorkingPattern for the specified tenant.\n\nRequires: Update on WorkingPatterns.",
        "operationId": "UpdateWorkingPattern",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkingPatternRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkingPatternDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "WorkingPatterns",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Time Tracking - Working Patterns"
        ],
        "summary": "Delete WorkingPattern",
        "description": "Deletes a WorkingPattern for the specified tenant.\n\nRequires: Delete on WorkingPatterns.",
        "operationId": "DeleteWorkingPattern",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "WorkingPatterns",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/write-off-reasons": {
      "get": {
        "tags": [
          "Time Tracking - Write-off Reasons"
        ],
        "summary": "List WriteOffReasons",
        "description": "Lists all WriteOffReasons for the given tenant.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "ListWriteOffReasons",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/WriteOffReasonSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "isActive",
            "in": "query",
            "description": "Filter by whether the reason is active (offered for new write-offs)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteOffReasonDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Time Tracking - Write-off Reasons"
        ],
        "summary": "Create WriteOffReason",
        "description": "Creates a new WriteOffReason for the specified tenant.\n\nRequires: Create on ClientBilling.",
        "operationId": "CreateWriteOffReason",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWriteOffReasonRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteOffReasonDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/write-off-reasons/{code}": {
      "get": {
        "tags": [
          "Time Tracking - Write-off Reasons"
        ],
        "summary": "Get WriteOffReason",
        "description": "Gets a WriteOffReason for the specified tenant.\n\nRequires: ViewAll on ClientBilling.",
        "operationId": "GetWriteOffReason",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteOffReasonDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Time Tracking - Write-off Reasons"
        ],
        "summary": "Update WriteOffReason",
        "description": "Updates a WriteOffReason for the specified tenant.\n\nRequires: Update on ClientBilling.",
        "operationId": "UpdateWriteOffReason",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWriteOffReasonRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteOffReasonDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Time Tracking - Write-off Reasons"
        ],
        "summary": "Delete WriteOffReason",
        "description": "Deletes a WriteOffReason for the specified tenant.\n\nRequires: Delete on ClientBilling.",
        "operationId": "DeleteWriteOffReason",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "ClientBilling",
            "permission": "Delete"
          }
        ]
      }
    },
    "/account/profile": {
      "get": {
        "tags": [
          "User - Account"
        ],
        "summary": "Get current user's profile",
        "description": "Returns the profile information of the currently authenticated user including first name, last name, and avatar",
        "operationId": "GetUserProfile",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserProfileResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      },
      "put": {
        "tags": [
          "User - Account"
        ],
        "summary": "Update current user's profile",
        "description": "Updates the currently authenticated user's profile information (first name and last name only). To update the avatar, use the PUT /account/avatar endpoint.",
        "operationId": "UpdateUserProfile",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateUserProfileRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserProfileResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "400": {
            "description": "Bad Request"
          }
        }
      }
    },
    "/account/avatar": {
      "put": {
        "tags": [
          "User - Account"
        ],
        "summary": "Set current user's avatar",
        "description": "Sets the currently authenticated user's avatar by uploading an image file. The image will be validated, processed (EXIF stripped), uploaded to blob storage, and the URL stored in the user profile. Maximum file size: 5MB. Allowed formats: PNG, JPEG, WEBP.",
        "operationId": "SetUserAvatar",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserProfileResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "400": {
            "description": "Bad Request"
          }
        }
      },
      "delete": {
        "tags": [
          "User - Account"
        ],
        "summary": "Remove current user's avatar",
        "description": "Removes the currently authenticated user's avatar",
        "operationId": "RemoveUserAvatar",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserProfileResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/account/utm": {
      "post": {
        "tags": [
          "User - Account"
        ],
        "summary": "Set UTM Info (write-once)",
        "description": "Sets the currently authenticated user's UTM tracking information. This is a write-once operation - if the user already has any UTM data, the request is silently ignored and returns 204 No Content. Returns 201 Created if UTM data was successfully stored.",
        "operationId": "SetUtmInfo",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UtmInfoDto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/users/invite-codes": {
      "get": {
        "tags": [
          "User - Account"
        ],
        "summary": "Get Invite Codes",
        "description": "Gets all invite codes for the authenticated user.",
        "operationId": "GetInviteCodes",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/InviteCodeDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/user-invitations": {
      "get": {
        "tags": [
          "User - Invitations"
        ],
        "summary": "List Pending Invitations",
        "description": "Returns:\n- 200 OK with list of pending invitations (empty list if none)\n- 400 Bad Request if email is not verified\n- 401 Unauthorized if not authenticated",
        "operationId": "GetInvitations",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/InvitationDetailsResponse"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "User - Invitations"
        ],
        "summary": "Process Invitation",
        "description": "Responds to the user's invitation to join the tenant.\n            \nReturns:\n- 200 OK with response details\n- 400 Bad Request if token invalid or email mismatch\n- 401 Unauthorized if not authenticated",
        "operationId": "ProcessInvitation",
        "requestBody": {
          "description": "The invitation response request",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessInvitationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProcessInvitationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "User - Invitations"
        ],
        "summary": "Send Invitation",
        "description": "Sends an invitation email to a user to join a tenant.\n            \nReturns:\n- 200 OK if invitation was sent\n- 400 Bad Request if user already accepted or invalid request\n- 401 Unauthorized if not authenticated\n- 404 Not Found if user doesn't exist in tenant",
        "operationId": "SendInvitation",
        "requestBody": {
          "description": "The send invitation request",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendInvitationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/tenants/{tenant}/user-notes": {
      "post": {
        "tags": [
          "User - Notes"
        ],
        "summary": "Create User Note",
        "description": "Creates a note owned by the calling user. The text is optional, so a note can be created empty and filled in later.\n\nOpen to any signed-in user of the tenant: The caller's own notes",
        "operationId": "CreateUserNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateUserNoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserNoteDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own notes"
      }
    },
    "/tenants/{tenant}/user-notes/{code}": {
      "get": {
        "tags": [
          "User - Notes"
        ],
        "summary": "Get User Note",
        "description": "Gets one of the calling user's own notes. Returns 404 for a note belonging to anybody else.\n\nOpen to any signed-in user of the tenant: The caller's own notes",
        "operationId": "GetUserNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserNoteDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own notes"
      },
      "put": {
        "tags": [
          "User - Notes"
        ],
        "summary": "Update User Note",
        "description": "Saves one of the calling user's own notes. Send an empty string to clear it.\n\nOpen to any signed-in user of the tenant: The caller's own notes",
        "operationId": "UpdateUserNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateUserNoteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserNoteDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own notes"
      },
      "delete": {
        "tags": [
          "User - Notes"
        ],
        "summary": "Delete User Note",
        "description": "Deletes one of the calling user's own notes.\n\nOpen to any signed-in user of the tenant: The caller's own notes",
        "operationId": "DeleteUserNote",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own notes"
      }
    },
    "/tenants/{tenant}/teams/my": {
      "get": {
        "tags": [
          "User - Teams"
        ],
        "summary": "List My Teams",
        "description": "Returns all teams the current user is a member of.\n\nOpen to any signed-in user of the tenant: The caller's own teams",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TeamDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own teams"
      }
    },
    "/tenants/{tenant}/teams": {
      "get": {
        "tags": [
          "User - Teams"
        ],
        "summary": "List Teams",
        "description": "Lists all Teams for the given tenant.\n\nRequires: ViewAll on Teams.",
        "operationId": "ListTeams",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TeamSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Teams",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "User - Teams"
        ],
        "summary": "Create Team",
        "description": "Creates a new Team for the specified tenant.\n\nRequires: Create on Teams.",
        "operationId": "CreateTeam",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTeamRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Teams",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/teams/{code}": {
      "get": {
        "tags": [
          "User - Teams"
        ],
        "summary": "Get Team",
        "description": "Gets a Team for the specified tenant.\n\nRequires: ViewAll on Teams.",
        "operationId": "GetTeam",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Teams",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "User - Teams"
        ],
        "summary": "Update Team",
        "description": "Updates a Team for the specified tenant.\n\nRequires: Update on Teams.",
        "operationId": "UpdateTeam",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTeamRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Teams",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "User - Teams"
        ],
        "summary": "Delete Team",
        "description": "Deletes a Team for the specified tenant.\n\nRequires: Delete on Teams.",
        "operationId": "DeleteTeam",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Teams",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/teams/{code}/members": {
      "get": {
        "tags": [
          "User - Teams"
        ],
        "summary": "List Team Members",
        "description": "Returns the members of a specific team.\n\nRequires: ViewAll on Teams.",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CodeAndNameDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Teams",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "User - Teams"
        ],
        "summary": "Add Team Members",
        "description": "Adds one or more users to a team.\n\nRequires: Update on Teams.",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddTeamMembersRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CodeAndNameDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Teams",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/teams/{code}/members/{userCode}": {
      "delete": {
        "tags": [
          "User - Teams"
        ],
        "summary": "Remove Team Member",
        "description": "Removes a user from a team.\n\nRequires: Update on Teams.",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          },
          {
            "name": "userCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 212
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Teams",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/user-view-preferences/{viewKey}": {
      "get": {
        "tags": [
          "User - View Preferences"
        ],
        "summary": "Get User View Preference",
        "description": "Gets the current user's view preference for a specific view key. Auto-creates an empty default if none exists.\n\nOpen to any signed-in user of the tenant: The caller's own view preferences",
        "operationId": "GetUserViewPreference",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "viewKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserViewPreferenceDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own view preferences"
      },
      "put": {
        "tags": [
          "User - View Preferences"
        ],
        "summary": "Upsert User View Preference",
        "description": "Creates or updates the current user's view preference for a specific view key.\n\nOpen to any signed-in user of the tenant: The caller's own view preferences",
        "operationId": "UpsertUserViewPreference",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "viewKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertUserViewPreferenceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserViewPreferenceDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own view preferences"
      }
    },
    "/users/me": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get current authenticated user",
        "description": "Returns the profile information of the currently authenticated user",
        "operationId": "GetCurrentUser",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrentUserResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/users/email-verification": {
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Verify user's email address",
        "description": "Verifies a user's email address using the verification key from the email link. Returns 200 if email is successfully verified (idempotent - also returns 200 if already verified). Returns 404 if the verification token is invalid or not found. Returns 410 if the token has expired - a new verification email is automatically sent in this case. Returns 400 for malformed requests (invalid GUID format, missing required fields).",
        "operationId": "VerifyEmail",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResponse"
                }
              }
            }
          },
          "410": {
            "description": "Gone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResponse"
                }
              }
            }
          }
        }
      }
    },
    "/users/email-verifications": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Resend email verification link",
        "description": "Resends a verification email to the authenticated user's email address.",
        "operationId": "ResendVerificationEmail",
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResendVerificationResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/tenants/{tenant}/users": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "List TenantUsers",
        "description": "Lists all TenantUsers for the given tenant.\n\nRequires: ViewAll on Users.",
        "operationId": "ListTenantUsers",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/TenantUserSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by user status (Created, Invited, Active, Disabled, Declined)",
            "schema": {
              "enum": [
                "Created",
                "Invited",
                "Active",
                "Disabled",
                "Declined",
                "Deleted"
              ],
              "type": "string",
              "example": "Active"
            }
          },
          {
            "name": "systemRole",
            "in": "query",
            "description": "Filter by system role (Admin, StandardUser, Viewer)",
            "schema": {
              "enum": [
                "Admin",
                "StandardUser",
                "Viewer"
              ],
              "type": "string",
              "example": "StandardUser"
            }
          },
          {
            "name": "isClientManager",
            "in": "query",
            "description": "Filter by client manager status (true = managers only, false = non-managers only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "isPartner",
            "in": "query",
            "description": "Filter by partner status (true = partners only, false = non-partners only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "isAssociate",
            "in": "query",
            "description": "Filter by associate status (true = associates only, false = non-associates only)",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across user code, first name, last name, and email (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "john"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantUserDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Create TenantUser",
        "description": "Creates a new TenantUser for the specified tenant. An hourly or cost rate seeds the user's first rate entry; setting a cost rate requires the Cost Rates permission.\n\nRequires: Create on Users.",
        "operationId": "CreateTenantUser",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTenantUserRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantUserDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/users/{code}": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get TenantUser",
        "description": "Gets a TenantUser for the specified tenant.\n\nRequires: ViewAll on Users.",
        "operationId": "GetTenantUser",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantUserDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Update TenantUser",
        "description": "Updates a TenantUser for the specified tenant.\n\nRequires: Update on Users.",
        "operationId": "UpdateTenantUser",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTenantUserRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantUserDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Users"
        ],
        "summary": "Delete TenantUser",
        "description": "Deletes a TenantUser for the specified tenant.\n\nRequires: Delete on Users.",
        "operationId": "DeleteTenantUser",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Delete"
          }
        ]
      },
      "patch": {
        "tags": [
          "Users"
        ],
        "summary": "Patch User",
        "description": "Applies a partial update to a user. Currently patches the time tracking fields: the working pattern (always applied — null clears it so the practice default applies) and the own-time restriction (applied only when the field is present; omit it to leave the restriction unchanged). Rates are managed via the user's rates endpoints. Putting a user on an existing pattern is a change to the user, so this needs Users.Update — defining the patterns themselves needs WorkingPatterns.\n\nRequires: Update on Users.",
        "operationId": "PatchTenantUser",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchTenantUserRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/users/me/other-email-addresses": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get My Other Email Addresses",
        "description": "The signed-in team member's other email addresses, each with any client or contact that also has it, and the accounts the practice's note takers are connected with that may be theirs. Other addresses are used only to recognise them as staff in meeting notes and email; nothing is sent to them and nobody signs in with them.\n\nOpen to any signed-in user of the tenant: The caller's own addresses",
        "operationId": "GetMyOtherEmailAddresses",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyOtherEmailAddressesDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own addresses"
      },
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Update My Other Email Addresses",
        "description": "Replaces the signed-in team member's other email addresses. Refused when an address is the one they sign in with or already belongs to someone else in the practice. An address a client or contact also has is saved; getting the addresses again shows the clash.\n\nOpen to any signed-in user of the tenant: The caller's own addresses",
        "operationId": "UpdateMyOtherEmailAddresses",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMyOtherEmailAddressesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "The caller's own addresses"
      }
    },
    "/tenants/{tenant}/users/by-email": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Find Staff By Email",
        "description": "Which of these email addresses (up to 50) belong to a team member, by the address they sign in with or one of their other addresses. A contact or client form uses it to warn that an address is a member of staff's.\n\nOpen to any signed-in user of the tenant: Team members' names and addresses are shown to every member of the practice",
        "operationId": "FindStaffByEmail",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FindStaffByEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StaffEmailOwnerDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Team members' names and addresses are shown to every member of the practice"
      }
    },
    "/tenants/{tenant}/users/{userCode}/rates": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "List User Rates",
        "description": "Lists the user's date-effective rate entries: the current entry first, then history by start date descending. Cost rates are null without the Cost Rates permission.\n\nRequires: ViewAll on Users.",
        "operationId": "ListTenantUserRates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 212
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TenantUserRateDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Change User Rate",
        "description": "Changes the user's current rates. With preserveHistory the current entry is closed the day before effectiveFrom and a new current entry begins; without it the current entry is corrected in place. Either way, rates already stamped on logged time entries are never changed. Setting a cost rate requires the Cost Rates permission.\n\nRequires: Update on Users.",
        "operationId": "ChangeTenantUserRate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 212
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeTenantUserRateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantUserRateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/users/{userCode}/rates/{rateCode}": {
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Update User Rate",
        "description": "Full replacement of one rate entry — for correcting a historical entry's rates or dates. The edited entry must not overlap the user's other entries, and at most one entry may be left without an end date. Setting a cost rate requires the Cost Rates permission.\n\nRequires: Update on Users.",
        "operationId": "UpdateTenantUserRate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 212
          },
          {
            "name": "rateCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTenantUserRateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantUserRateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Users"
        ],
        "summary": "Delete User Rate",
        "description": "Deletes one rate entry. Deleting the current entry leaves the user with no rate of their own, so the practice default applies to newly logged time until a new rate is set. Deleting an entry that holds a cost rate requires the Cost Rates permission.\n\nRequires: Update on Users.",
        "operationId": "DeleteTenantUserRate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 212
          },
          {
            "name": "rateCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/work-type-rates/team-members": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "List Team Member Work Type Rates",
        "description": "Lists every team member's current rate for each task category or service they have one for, with the team member's code, ordered by type of work. Practice-level rates are not included. Cost rates are null without the Cost Rates permission.\n\nRequires: ViewAll on Users.",
        "operationId": "ListTeamMemberWorkTypeRates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkTypeRateDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/users/{userCode}/work-type-rates": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "List User Work Type Rates",
        "description": "Lists the team member's rates by task category or service, grouped by type of work: each one's current entry first, then history by start date descending. Cost rates are null without the Cost Rates permission.\n\nRequires: ViewAll on Users.",
        "operationId": "ListUserWorkTypeRates",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 212
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkTypeRateDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Change User Work Type Rate",
        "description": "Sets the team member's current rate for a task category or a service. With preserveHistory the current entry is closed the day before effectiveFrom and a new current entry begins; without it the current entry is corrected in place. Rates already stamped on logged time are not changed. Setting a cost rate requires the Cost Rates permission.\n\nRequires: Update on Users.",
        "operationId": "ChangeUserWorkTypeRate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 212
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeWorkTypeRateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkTypeRateDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/users/{userCode}/work-type-rates/{rateCode}": {
      "delete": {
        "tags": [
          "Users"
        ],
        "summary": "Delete User Work Type Rate",
        "description": "Deletes one rate entry. Deleting the current entry leaves that type of work with no rate of its own, so the next rule down applies to newly logged time. Deleting an entry that holds a cost rate requires the Cost Rates permission.\n\nRequires: Update on Users.",
        "operationId": "DeleteUserWorkTypeRate",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "userCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 212
          },
          {
            "name": "rateCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Users",
            "permission": "Update"
          }
        ]
      }
    },
    "/webhooks/{provider}/{token}": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Receive Webhook",
        "description": "Receives one webhook delivery from a third-party platform (e.g. FuseSign). The token identifies the tenant's connection; the provider's signature header verifies origin. Events are persisted and processed asynchronously — 200 means durably received, including redeliveries of an event already held.",
        "operationId": "ReceiveWebhook",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          },
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "x-order": 400
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Not Found"
          },
          "413": {
            "description": "Content Too Large"
          }
        }
      }
    },
    "/tenants/{tenant}/pending-workflow-steps": {
      "get": {
        "tags": [
          "Workflow Steps - Pending"
        ],
        "summary": "List Pending Workflow Steps",
        "description": "Returns a paged list of manual-mode outbound workflow steps that are ready to send. These are steps where dependencies are met and a user needs to review and trigger the send.\n\nRequires: ViewAll on Tasks.",
        "operationId": "ListPendingWorkflowSteps",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/PendingWorkflowStepSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "stepType",
            "in": "query",
            "description": "Filter by step type (SendEmail, DocumentRequest, DocumentApproval, ClientConfirmation, SendDataForm)",
            "schema": {
              "enum": [
                "Standard",
                "SendEmail",
                "DocumentRequest",
                "DocumentApproval",
                "ClientConfirmation",
                "SendDataForm",
                "SetServiceStage",
                "UpdateClientData",
                "SetPipelineStage",
                "DocumentUpload",
                "ReviewLoggedTime",
                "BillForWork",
                "CisCollectPayments",
                "CisConfirmReturn",
                "CisSubmitReturn",
                "CisVerifySubcontractors",
                "CisFileNilReturn",
                "CisRemindPayments",
                "SendTextMessage"
              ],
              "type": "string",
              "example": "SendEmail"
            }
          },
          {
            "name": "assignedUserCode",
            "in": "query",
            "description": "Filter by the user assigned to the step",
            "schema": {
              "type": "string",
              "example": "USR001"
            }
          },
          {
            "name": "assignedTeamCode",
            "in": "query",
            "description": "Filter by the team assigned to the step",
            "schema": {
              "type": "string",
              "example": "TEAM001"
            }
          },
          {
            "name": "isUnassigned",
            "in": "query",
            "description": "When true, returns only steps with no assigned user. Combines with assignedUserCode as OR.",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "clientCode",
            "in": "query",
            "description": "Filter by client code",
            "schema": {
              "type": "string",
              "example": "acme-ltd"
            }
          },
          {
            "name": "managerCode",
            "in": "query",
            "description": "Filter by client manager user code",
            "schema": {
              "type": "string",
              "example": "USR001"
            }
          },
          {
            "name": "partnerCode",
            "in": "query",
            "description": "Filter by client partner user code",
            "schema": {
              "type": "string",
              "example": "USR002"
            }
          },
          {
            "name": "taskCategoryCode",
            "in": "query",
            "description": "Filter by task category code",
            "schema": {
              "type": "string",
              "example": "CAT001"
            }
          },
          {
            "name": "taskCode",
            "in": "query",
            "description": "Restrict to steps belonging to these tasks - can specify multiple",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "example": "[ \"bookkeeping-jul-26\", \"bookkeeping-aug-26\" ]"
            }
          },
          {
            "name": "autoExecute",
            "in": "query",
            "description": "Null or false returns manual steps awaiting a person. True returns auto steps that are ready to run - what would happen if the task's automation were switched on.",
            "schema": {
              "type": "boolean",
              "example": "true"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search across step name, task title, and client name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "tax return"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingWorkflowStepDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "ViewAll"
          }
        ]
      },
      "patch": {
        "tags": [
          "Workflow Steps - Pending"
        ],
        "summary": "Bulk Update Workflow Steps",
        "description": "Updates multiple workflow steps at once. Supports skipping steps and reassigning to a user.\n\nRequires: Update on Tasks.",
        "operationId": "BulkUpdatePendingWorkflowSteps",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkUpdateWorkflowStepsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Tasks",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "List Workflows",
        "description": "Lists all Workflows for the given tenant.\n\nRequires: ViewAll on Workflows.",
        "operationId": "ListWorkflows",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Number of records to skip (default: 0). Use with limit for pagination.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "0"
            },
            "x-order": 500
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return (default: 10, max: 50)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "example": "20"
            },
            "x-order": 501
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by. Valid values depend on the resource.",
            "schema": {
              "$ref": "#/components/schemas/WorkflowSortField"
            },
            "x-order": 502
          },
          {
            "name": "sortDesc",
            "in": "query",
            "description": "Sort in descending order (true) or ascending order (false, default)",
            "schema": {
              "type": "boolean",
              "example": "false"
            },
            "x-order": 503
          },
          {
            "name": "customFieldCode",
            "in": "query",
            "description": "Only workflows with a group or step whose condition is this custom field",
            "schema": {
              "type": "string",
              "example": "favourite_colour"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search term to filter results",
            "schema": {
              "type": "string",
              "example": "keyword"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowDtoPagedResult"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "ViewAll"
          }
        ]
      },
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Create Workflow",
        "description": "Creates a new Workflow for the specified tenant.\n\nRequires: Create on Workflows.",
        "operationId": "CreateWorkflow",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkflowRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows/{code}": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "Get Workflow",
        "description": "Gets a Workflow for the specified tenant.\n\nRequires: ViewAll on Workflows.",
        "operationId": "GetWorkflow",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "ViewAll"
          }
        ]
      },
      "put": {
        "tags": [
          "Workflows"
        ],
        "summary": "Update Workflow",
        "description": "Updates a Workflow for the specified tenant.\n\nRequires: Update on Workflows.",
        "operationId": "UpdateWorkflow",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkflowRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "Update"
          }
        ]
      },
      "delete": {
        "tags": [
          "Workflows"
        ],
        "summary": "Delete Workflow",
        "description": "Deletes a Workflow for the specified tenant.\n\nRequires: Delete on Workflows.",
        "operationId": "DeleteWorkflow",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "Delete"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows/library": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "List Library Workflows",
        "description": "List all Workflows available in the library as templates. Use optional 'search' query parameter to filter by Code, Name, or Description.\n\nRequires: ViewAll on Workflows.",
        "operationId": "ListLibraryWorkflows",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "x-order": 150
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkflowDto"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows/library/{code}": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "Get Library Workflow",
        "description": "Get details of a specific Workflow template from the library\n\nRequires: ViewAll on Workflows.",
        "operationId": "GetLibraryWorkflow",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows/{code}/library-version": {
      "put": {
        "tags": [
          "Workflows"
        ],
        "summary": "Revert Workflow to Library",
        "description": "Reverts the Workflow to the current library template version, overwriting any local edits. The Workflow's code is preserved so it remains addressable at the same URL. Returns 400 if the Workflow was not imported from the library, or 404 if the Workflow or its source library template no longer exists.\n\nRequires: Update on Workflows.",
        "operationId": "RevertWorkflowToLibraryVersion",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 2
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows/library/{libraryCode}/import": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Import from Library",
        "description": "Imports a workflow from the library, creating a new tenant copy each call. Re-imports of the same library item are supported and produce a fresh row with the supplied NameSuffix appended (or auto '(N)' when omitted).\n\nRequires: Create on Workflows.",
        "operationId": "ImportWorkflowFromLibrary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "libraryCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 400
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportFromLibraryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows/library/import": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Import Workflows from Library",
        "description": "Imports one or more workflows from the library, creating a new tenant copy of each. Re-imports produce fresh rows with the supplied NameSuffix appended (or auto '(N)' when omitted).\n\nRequires: Create on Workflows.",
        "operationId": "ImportWorkflowsFromLibrary",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportWorkflowsFromLibraryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkflowDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows/generate": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Generate Workflow",
        "description": "Generates a complete Workflow DTO with AI-generated groups and steps based on the workflow name and description\n\nRequires: Create on Workflows.",
        "operationId": "GenerateWorkflow",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateWorkflowRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowDto"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "Create"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows/preview-step-email": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Preview Step Email",
        "description": "Renders a SendEmail workflow step's email as the chosen client would receive it, anchored on the supplied task start date. Takes the step configuration in the body rather than reading a saved workflow, so an unsaved step can be previewed mid-edit. Placeholders that resolve to nothing are listed on unresolvedTokens. Nothing is sent or stored.\n\nRequires: ViewAll on Workflows.",
        "operationId": "PreviewWorkflowStepEmail_Template",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewWorkflowStepEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepEmailPreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/workflows/preview-step-text": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Preview Step Text",
        "description": "Renders a Send Text Message workflow step's text (its text template or its own text) as edited, for the chosen client and the first of its contacts the step would text. Without a client only the practice and date tokens are filled. There is no task, so the Task tokens render empty. Nothing is sent or stored.\n\nRequires: ViewAll on Workflows.",
        "operationId": "PreviewWorkflowStepText_Template",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewWorkflowStepTextRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStepTextTemplatePreviewDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "Workflows",
            "permission": "ViewAll"
          }
        ]
      }
    },
    "/tenants/{tenant}/working-days": {
      "get": {
        "tags": [
          "Working Days"
        ],
        "summary": "Get Working Days Settings",
        "description": "Returns the working days configuration including bank holiday region and default holiday adjustment behavior for task scheduling\n\nOpen to any signed-in user of the tenant: Practice-wide reference settings, readable by every user in the practice",
        "operationId": "GetWorkingDays",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkingDaySettingsDto"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Practice-wide reference settings, readable by every user in the practice"
      },
      "put": {
        "tags": [
          "Working Days"
        ],
        "summary": "Update Working Days Settings",
        "description": "Updates the working days configuration for the tenant\n\nRequires: Update on PracticeDetails.",
        "operationId": "UpdateWorkingDays",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkingDaySettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkingDaySettingsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "403": {
            "description": "Forbidden – the caller lacks the permissions this endpoint requires; the detail lists every one missing",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-required-permissions": [
          {
            "entity": "PracticeDetails",
            "permission": "Update"
          }
        ]
      }
    },
    "/tenants/{tenant}/bank-holidays": {
      "get": {
        "tags": [
          "Working Days"
        ],
        "summary": "List Bank Holidays",
        "description": "Returns bank holidays for the tenant's configured region. Filter by year (defaults to current year) and search by name.\n\nOpen to any signed-in user of the tenant: Public dates for the practice's region, readable by every user in the practice",
        "operationId": "ListBankHolidays",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "The Tenant.Code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "x-order": 0
          },
          {
            "name": "year",
            "in": "query",
            "description": "Filter by year. Defaults to current year if not specified.",
            "schema": {
              "type": "integer",
              "example": "2025"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search by holiday name (minimum 3 characters)",
            "schema": {
              "type": "string",
              "example": "christmas"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BankHolidayDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized – Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "x-no-permission-reason": "Public dates for the practice's region, readable by every user in the practice"
      }
    }
  },
  "components": {
    "schemas": {
      "AcceptanceDto": {
        "type": "object",
        "properties": {
          "acceptedDate": {
            "type": "string",
            "description": "Date and time when the engagement was accepted",
            "format": "date-time",
            "nullable": true
          },
          "acceptedIpAddress": {
            "type": "string",
            "description": "IP address from which the engagement was accepted (for audit purposes)",
            "nullable": true
          },
          "acceptanceSignature": {
            "type": "string",
            "description": "Digital signature data from the acceptance (base64 encoded image)",
            "nullable": true
          },
          "acceptedByName": {
            "type": "string",
            "description": "Name as typed by the signee at acceptance time",
            "nullable": true
          },
          "acceptedUserAgent": {
            "type": "string",
            "description": "Browser user agent string captured at acceptance time",
            "nullable": true
          },
          "manuallyAccepted": {
            "type": "boolean",
            "description": "Indicates whether the engagement was manually accepted (true) or accepted via the online acceptance page (false)"
          },
          "acceptanceSignatureImage": {
            "type": "string",
            "description": "Digital signature as an HTML img tag for template rendering.\nConverts the base64-encoded signature to an img element with data URI.",
            "nullable": true,
            "readOnly": true
          }
        },
        "additionalProperties": false,
        "description": "Acceptance information for an engagement"
      },
      "AcceptanceStepStatus": {
        "enum": [
          "Outstanding",
          "Complete",
          "Unknown"
        ],
        "type": "string",
        "example": "Outstanding"
      },
      "AccountingLinkResponse": {
        "required": [
          "id",
          "platform",
          "url"
        ],
        "type": "object",
        "properties": {
          "platform": {
            "type": "string",
            "description": "The accounting platform's code (e.g. \"freeagent\").",
            "nullable": true
          },
          "id": {
            "type": "string",
            "description": "The record's ID on the platform.",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "The browser URL of the record on the platform.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A record on Sodium's accounting platform (a customer or an invoice): which platform holds it,\nits ID there, and the URL that opens it in a browser."
      },
      "AccountingPeriodResponseDto": {
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "description": "The period's start date.",
            "format": "date"
          },
          "end": {
            "type": "string",
            "description": "The period's end date.",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "One accounting period for an income source."
      },
      "AddAmlContactRequest": {
        "required": [
          "clientCode",
          "clientContactCode"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "minLength": 1,
            "type": "string",
            "description": "The Sodium client code that owns this contact relationship."
          },
          "clientContactCode": {
            "minLength": 1,
            "type": "string",
            "description": "The Sodium client-contact code (same as the contact's code) identifying which contact to push."
          }
        },
        "additionalProperties": false,
        "description": "Request to push a Sodium contact to the AML platform.\nThe API looks up all contact fields server-side from the client-contact relationship."
      },
      "AddMtdCustomEmploymentRequest": {
        "required": [
          "employerName",
          "occupationalPension",
          "startDate"
        ],
        "type": "object",
        "properties": {
          "employerRef": {
            "maxLength": 14,
            "type": "string",
            "description": "The employer's PAYE reference, in HMRC's format (e.g. 123/AB456).",
            "nullable": true
          },
          "employerName": {
            "maxLength": 74,
            "minLength": 1,
            "type": "string",
            "description": "The employer's name. Required by HMRC."
          },
          "startDate": {
            "type": "string",
            "description": "The employment's start date. Required by HMRC.",
            "format": "date"
          },
          "cessationDate": {
            "type": "string",
            "description": "The employment's cessation date, when it ended in the year.",
            "format": "date",
            "nullable": true
          },
          "payrollId": {
            "maxLength": 38,
            "type": "string",
            "description": "The payroll identifier.",
            "nullable": true
          },
          "occupationalPension": {
            "type": "boolean",
            "description": "Whether the employment is an occupational pension. Required by HMRC and not defaulted — it\nchanges how the income is taxed, so it is an answer rather than a blank."
          }
        },
        "additionalProperties": false,
        "description": "Adds a custom employment for a tax year — an employment HMRC do not already hold from the\nemployer's own submissions. HMRC issue the identifier every later call uses.\n            \nThis is only for employments HMRC are missing. Adding one that duplicates an HMRC-held\nemployment double-counts the income; the way to remove an HMRC-held employment from the\ncalculation is to ignore it, not to add a replacement."
      },
      "AddMtdSavingsAccountRequest": {
        "required": [
          "accountName"
        ],
        "type": "object",
        "properties": {
          "accountName": {
            "maxLength": 32,
            "minLength": 1,
            "type": "string",
            "description": "The account's display name. HMRC require it to be unique for the client, and cap it at 32\ncharacters — the same cap is applied here so the user is told before the round trip."
          }
        },
        "additionalProperties": false,
        "description": "Registers a UK savings account for the client at HMRC. Accounts are registered once rather than\nper tax year, and HMRC issue the identifier every later call uses."
      },
      "AddTeamMembersRequest": {
        "required": [
          "userCodes"
        ],
        "type": "object",
        "properties": {
          "userCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The user codes of the members to add"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for adding members to a team"
      },
      "AddUngroupedSenderRequest": {
        "required": [
          "sender"
        ],
        "type": "object",
        "properties": {
          "sender": {
            "maxLength": 255,
            "minLength": 1,
            "type": "string",
            "description": "An email address (noreply@hmrc.gov.uk) or a domain (hmrc.gov.uk, which also covers its subdomains)"
          }
        },
        "additionalProperties": false,
        "description": "Request to add one address or domain to a mailbox's ungrouped senders"
      },
      "AgentAuthorisationCountsDto": {
        "type": "object",
        "properties": {
          "byStatus": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Counts keyed by authorisation status name.",
            "nullable": true
          },
          "byVerificationResult": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Counts keyed by HMRC verification result name, or absent when no Making Tax Digital type was\nrequested — the letter-based types are never checked with HMRC.",
            "nullable": true
          },
          "supportingAgentCount": {
            "type": "integer",
            "description": "How many authorisations HMRC confirmed are held as a supporting agent.",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Practice-wide tallies of required agent authorisations, counted across every client rather\nthan one page."
      },
      "AgentAuthorisationStatus": {
        "enum": [
          "NotRequested",
          "Requested",
          "Granted"
        ],
        "type": "string",
        "example": "NotRequested"
      },
      "AgentAuthorisationSummaryClientDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code.",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name.",
            "nullable": true
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentAuthorisationSummaryEntryDto"
            },
            "description": "One entry per authorisation type this client's services require.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One client on the authorisation summary, with an entry per authorisation type its active or\nproposed services require. A type the client does not need simply has no entry."
      },
      "AgentAuthorisationSummaryClientDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentAuthorisationSummaryClientDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "AgentAuthorisationSummaryEntryDto": {
        "type": "object",
        "properties": {
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          },
          "status": {
            "$ref": "#/components/schemas/AgentAuthorisationStatus"
          },
          "hmrcAgentRole": {
            "$ref": "#/components/schemas/HmrcAgentRole"
          },
          "verificationResult": {
            "$ref": "#/components/schemas/HmrcVerificationResult"
          },
          "canVerify": {
            "type": "boolean",
            "description": "Whether enough is known about the client to ask HMRC. Only meaningful for the Making Tax\nDigital types — always false for the letter-based ones, which HMRC offer no check for."
          }
        },
        "additionalProperties": false,
        "description": "One authorisation type a client's services require, and what the practice holds against it."
      },
      "AgentAuthorisationType": {
        "enum": [
          "SelfAssessment",
          "CorporationTax",
          "PayeForEmployers",
          "IndividualPayAsYouEarn",
          "VAT",
          "ConstructionIndustryScheme",
          "TaxCredits",
          "HighIncomeChildBenefitCharge",
          "MakingTaxDigitalIncomeTax",
          "MakingTaxDigitalVat",
          "Trusts"
        ],
        "type": "string",
        "example": "SelfAssessment"
      },
      "AiActivity": {
        "enum": [
          "ServiceGen",
          "ProposalContentGen",
          "ServiceScheduleGen",
          "DescriptionGen",
          "PricingFactorsGen",
          "PricingFactorOptionsGen",
          "WorkflowGen",
          "ConversationSummaryGen",
          "EmailPolishGen",
          "ClientNotesSummaryGen"
        ],
        "type": "string",
        "example": "ServiceGen"
      },
      "AiContext": {
        "enum": [
          "AccountancyPractice",
          "BookkeepingPractice"
        ],
        "type": "string",
        "example": "AccountancyPractice"
      },
      "AiGenerationRequest": {
        "required": [
          "activity",
          "input"
        ],
        "type": "object",
        "properties": {
          "activity": {
            "$ref": "#/components/schemas/AiActivity"
          },
          "input": {
            "minLength": 1,
            "type": "string",
            "description": "The input text or context for the AI generation"
          },
          "code": {
            "type": "string",
            "description": "Optional code of the related entity (e.g., service code, client code)",
            "nullable": true
          },
          "useCache": {
            "type": "boolean",
            "description": "Whether to use cached AI responses if available (default: true)"
          }
        },
        "additionalProperties": false,
        "description": "Request to generate content using AI based on the specified activity"
      },
      "AiModelDto": {
        "type": "object",
        "properties": {
          "value": {
            "type": "string",
            "description": "The model identifier to save in the AI settings (e.g. \"openai/gpt-4o-mini\")",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The name to show the user (e.g. \"GPT-4o-mini\")",
            "nullable": true
          },
          "provider": {
            "$ref": "#/components/schemas/AiProvider"
          }
        },
        "additionalProperties": false,
        "description": "A model a practice can choose in its AI settings"
      },
      "AiProvider": {
        "enum": [
          "OpenAi",
          "Anthropic",
          "Google"
        ],
        "type": "string",
        "example": "OpenAi"
      },
      "AiRegion": {
        "enum": [
          "Global",
          "Europe"
        ],
        "type": "string",
        "example": "Global"
      },
      "AiSettingsDto": {
        "type": "object",
        "properties": {
          "useCustomKey": {
            "type": "boolean",
            "description": "Whether to use a custom OpenAI API key instead of the shared platform key"
          },
          "customKey": {
            "type": "string",
            "description": "The custom OpenAI API key (only used if UseCustomKey is true)",
            "nullable": true
          },
          "model": {
            "type": "string",
            "description": "The OpenRouter model identifier to use (e.g., \"openai/gpt-4o-mini\", or \"default\" for platform default). Must be one of the models from the list of AI models, unless the practice uses its own key, which may use any model.",
            "nullable": true
          },
          "region": {
            "$ref": "#/components/schemas/AiRegion"
          },
          "useBritishEnglish": {
            "type": "boolean",
            "description": "Whether to use British English spelling and conventions in AI-generated content"
          },
          "context": {
            "$ref": "#/components/schemas/AiContext"
          },
          "modelServicesScheduleContent": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "modelProposalsContent": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "Configuration for AI/LLM integration settings at the tenant level.\nControls which AI model to use and whether to use a custom API key or the shared platform key.\nIncludes references to content blocks that provide context for AI-generated content in proposals and service schedules."
      },
      "AiUsageSummaryDto": {
        "type": "object",
        "properties": {
          "userSharedKeyTokens": {
            "type": "integer",
            "description": "Total tokens used by the current user with the shared API key",
            "format": "int32"
          },
          "userCustomKeyTokens": {
            "type": "integer",
            "description": "Total tokens used by the current user with their custom API key",
            "format": "int32"
          },
          "tenantSharedKeyTokens": {
            "type": "integer",
            "description": "Total tokens used by all users in the tenant with the shared API key",
            "format": "int32"
          },
          "tenantCustomKeyTokens": {
            "type": "integer",
            "description": "Total tokens used by all users in the tenant with their custom API keys",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Summary of AI usage tokens for a specific date range"
      },
      "AmendMtdBroughtForwardLossRequest": {
        "required": [
          "lossAmount"
        ],
        "type": "object",
        "properties": {
          "lossAmount": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "The replacement amount, as a positive figure. Must differ from what HMRC hold.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Changes a brought forward loss's amount — the only part of a loss HMRC let you change.\n            \nA <strong>POST</strong> rather than a PUT throughout, mirroring HMRC: they refuse an amend that\nchanges nothing (`RULE_NO_CHANGE`), so a save button that re-sends unchanged values fails\ninstead of doing nothing."
      },
      "AmendMtdCustomEmploymentRequest": {
        "required": [
          "employerName",
          "occupationalPension",
          "startDate"
        ],
        "type": "object",
        "properties": {
          "employerRef": {
            "maxLength": 14,
            "type": "string",
            "description": "The employer's PAYE reference.",
            "nullable": true
          },
          "employerName": {
            "maxLength": 74,
            "minLength": 1,
            "type": "string",
            "description": "The employer's name. Required by HMRC."
          },
          "startDate": {
            "type": "string",
            "description": "The employment's start date. Required by HMRC.",
            "format": "date"
          },
          "cessationDate": {
            "type": "string",
            "description": "The employment's cessation date, when it ended in the year.",
            "format": "date",
            "nullable": true
          },
          "payrollId": {
            "maxLength": 38,
            "type": "string",
            "description": "The payroll identifier.",
            "nullable": true
          },
          "occupationalPension": {
            "type": "boolean",
            "description": "Whether the employment is an occupational pension. Required by HMRC."
          }
        },
        "additionalProperties": false,
        "description": "Amends a custom employment — a <strong>full replacement</strong> of its record at HMRC, so\nevery value that should survive must be present.\n            \nOnly custom employments can be amended. An employment HMRC hold from the employer's own\nsubmissions is theirs to correct; the way to take it out of the calculation is to ignore it."
      },
      "AmendMtdLossClaimTypeRequest": {
        "required": [
          "typeOfClaim"
        ],
        "type": "object",
        "properties": {
          "typeOfClaim": {
            "$ref": "#/components/schemas/HmrcLossClaimType"
          }
        },
        "additionalProperties": false,
        "description": "Changes an existing loss claim's type — the only part of a claim HMRC let you amend."
      },
      "AmendMtdLossClaimsOrderRequest": {
        "required": [
          "claims"
        ],
        "type": "object",
        "properties": {
          "claims": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LossClaimOrderItem"
            },
            "description": "Every carry-sideways claim for the tax year, each with its position."
          }
        },
        "additionalProperties": false,
        "description": "Replaces the order in which HMRC apply the year's carry-sideways loss claims.\n            \nA full replacement, and HMRC mean it: every carry-sideways claim for the year must be in the\nlist, positioned from 1 upwards with no gaps. Sending a subset is refused, not merged."
      },
      "AmlClientDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "externalReference": {
            "type": "string",
            "description": "The platform's own reference for the client. Firmcheck stores the Sodium client code here on\ncreate, so it identifies a client in a list that cannot be searched.",
            "nullable": true
          },
          "isIndividual": {
            "type": "boolean"
          },
          "isSoleTrader": {
            "type": "boolean",
            "description": "The client is held as a sole trader on the platform (Firmcheck only; false on Xama)."
          },
          "regNumber": {
            "type": "string",
            "nullable": true
          },
          "contacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AmlContactDto"
            },
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/AmlStatus"
          },
          "riskLevel": {
            "$ref": "#/components/schemas/AmlRiskLevel"
          },
          "determinationStatus": {
            "$ref": "#/components/schemas/AmlContactStatus"
          },
          "nextReviewDate": {
            "type": "string",
            "description": "When the platform expects the client to be reviewed next. Null until a determination has\ncompleted, and always null on Xama.",
            "format": "date",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "AmlClientDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AmlClientDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "AmlClientSortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "AmlContactDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "middleName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "nullable": true
          },
          "address": {
            "type": "string",
            "nullable": true
          },
          "companiesHousePersonalCode": {
            "type": "string",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "nullable": true
          },
          "onboardingStatus": {
            "$ref": "#/components/schemas/AmlContactStatus"
          },
          "amlStatus": {
            "$ref": "#/components/schemas/AmlContactStatus"
          }
        },
        "additionalProperties": false,
        "description": "Contact details from the AML platform."
      },
      "AmlContactStatus": {
        "enum": [
          "NotStarted",
          "InProgress",
          "Ready",
          "InReview",
          "Complete",
          "ActionRequired",
          "Cancelled"
        ],
        "type": "string",
        "example": "NotStarted"
      },
      "AmlMailTemplateDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean"
          }
        },
        "additionalProperties": false,
        "description": "A mail template configured in the AML platform."
      },
      "AmlOnboardingLevelDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean"
          }
        },
        "additionalProperties": false,
        "description": "An onboarding level configured in the AML platform."
      },
      "AmlOnboardingUrlResponse": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "The onboarding URL. Null if no onboarding report exists or the URL is no longer available.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response containing the onboarding URL for a contact."
      },
      "AmlRiskAssessmentDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/AmlRiskAssessmentStatus"
          },
          "riskLevel": {
            "$ref": "#/components/schemas/AmlRiskLevel"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "reviewNotes": {
            "type": "string",
            "nullable": true
          },
          "preparedBy": {
            "type": "string",
            "nullable": true
          },
          "reviewedBy": {
            "type": "string",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "AmlRiskAssessmentDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AmlRiskAssessmentDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "AmlRiskAssessmentStatus": {
        "enum": [
          "InProgress",
          "InReview",
          "Completed"
        ],
        "type": "string",
        "example": "InProgress"
      },
      "AmlRiskLevel": {
        "enum": [
          "Low",
          "Normal",
          "High",
          "Medium"
        ],
        "type": "string",
        "example": "Low"
      },
      "AmlStatus": {
        "enum": [
          "Active",
          "Pending",
          "Archived"
        ],
        "type": "string",
        "example": "Active"
      },
      "AnswerDocumentRequestItemRequest": {
        "type": "object",
        "properties": {
          "text": {
            "maxLength": 4000,
            "type": "string",
            "description": "The answer text",
            "nullable": true
          },
          "cannotProvide": {
            "type": "boolean",
            "description": "The client cannot provide this. Counts as an answer."
          }
        },
        "additionalProperties": false,
        "description": "An answer to one item: the client's draft, or a member of staff answering on the client's behalf"
      },
      "ApiKeyDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "The unique identifier for this API key (use this for authentication via x-api-key header)",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "The friendly name for this API key",
            "nullable": true
          },
          "isScoped": {
            "type": "boolean",
            "description": "Whether this key is scoped to a tenant + role. Unscoped keys fully impersonate their\nowner in every tenant they belong to."
          },
          "tenant": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "roleType": {
            "$ref": "#/components/schemas/RoleType"
          },
          "role": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "isSendBlocked": {
            "type": "boolean",
            "description": "Whether this key is refused on every endpoint that sends a message (email, SMS, WhatsApp)"
          },
          "createdDate": {
            "type": "string",
            "description": "The date this API key was created",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Represents an API key for authentication"
      },
      "ApplyExternalProposalRequest": {
        "type": "object",
        "properties": {
          "createOnboardingTasks": {
            "type": "boolean",
            "description": "Whether the services the proposal adds as Active get their onboarding tasks. Defaults to creating them."
          },
          "startDate": {
            "type": "string",
            "description": "When the services the proposal adds start. Defaults to the proposal's planned start, or today when it has none.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Choices made when applying an external proposal to its client"
      },
      "ApplyExternalProposalResponse": {
        "type": "object",
        "properties": {
          "createdCount": {
            "type": "integer",
            "description": "Services created for lines the client did not have",
            "format": "int32"
          },
          "activatedCount": {
            "type": "integer",
            "description": "Proposed services activated because the proposal is won",
            "format": "int32"
          },
          "updatedCount": {
            "type": "integer",
            "description": "Services whose price or billing period was updated to the proposal's",
            "format": "int32"
          },
          "needsHandEdit": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Titles of the lines Sodium left for a hand edit (the client holds the service more than once,\nor its price comes from a package)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What applying an external proposal to its client did"
      },
      "ApplyForMessagingNumberRequest": {
        "required": [
          "address",
          "businessName",
          "registrationAuthority",
          "registrationNumber",
          "representative",
          "website"
        ],
        "type": "object",
        "properties": {
          "businessName": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The registered business name"
          },
          "registrationAuthority": {
            "$ref": "#/components/schemas/MessagingRegistrationAuthority"
          },
          "registrationNumber": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The registration number: a company number for Companies House, else a UTR or VAT number"
          },
          "website": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "The public website, or a verified social media page",
            "format": "uri"
          },
          "address": {
            "$ref": "#/components/schemas/MessagingNumberApplicationAddressDto"
          },
          "representative": {
            "$ref": "#/components/schemas/MessagingNumberApplicationRepresentativeDto"
          },
          "requestedPhoneNumber": {
            "maxLength": 30,
            "minLength": 0,
            "type": "string",
            "description": "The number chosen from the available numbers, E.164; null for the first available. A chosen number taken\nbefore approval is replaced by the next available.",
            "nullable": true
          },
          "agreedToCosts": {
            "type": "boolean",
            "description": "The applicant agrees to the number's monthly price and to paying for the credits the practice buys, as the page\nshowed them. Must be true."
          }
        },
        "additionalProperties": false,
        "description": "Applies for the practice's own number: the details, and the applicant's agreement to the costs"
      },
      "ApplyHmrcClientListRequest": {
        "required": [
          "authorisationType",
          "changes"
        ],
        "type": "object",
        "properties": {
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          },
          "changes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HmrcClientListChangeDto"
            },
            "description": "The clients to change. Granted for clients on the list; Not Requested for granted clients missing from it."
          }
        },
        "additionalProperties": false,
        "description": "The statuses the practice confirmed after checking an HMRC client list."
      },
      "ApplyServicePackageRequest": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "startDate": {
            "type": "string",
            "description": "The start date for the services. Defaults to today if not provided.",
            "format": "date-time",
            "nullable": true
          },
          "createOnboardingTasks": {
            "type": "boolean",
            "description": "Whether to create onboarding tasks for the assigned services. Defaults to true."
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for applying a service package to a client"
      },
      "ApplyTimeEntryRateRecalculationRequest": {
        "required": [
          "fromDate",
          "timeEntryCodes"
        ],
        "type": "object",
        "properties": {
          "fromDate": {
            "type": "string",
            "description": "The first entry date to include",
            "format": "date"
          },
          "userCode": {
            "maxLength": 100,
            "type": "string",
            "description": "Limits the entries to one team member",
            "nullable": true
          },
          "timeEntryCodes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The entries to update, from the preview"
          }
        },
        "additionalProperties": false,
        "description": "Re-applies the current rates to the chosen entries from a preview. The rates are worked out\nagain on the server, so an entry gets the rates that apply now, not what the preview showed."
      },
      "ApproveTimePaymentRequest": {
        "required": [
          "timeEntryCodes"
        ],
        "type": "object",
        "properties": {
          "timeEntryCodes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the time entries to approve or un-approve"
          },
          "approved": {
            "type": "boolean",
            "description": "True to approve the entries for payment, false to clear an existing approval"
          }
        },
        "additionalProperties": false,
        "description": "Request to approve (or un-approve) time entries for payment to the team members who\nlogged them. Entries must be unpaid and belong to members the practice pays for\ntracked time; paid entries can only change via their pay run."
      },
      "AssignClientScheduleRequest": {
        "required": [
          "scheduleCode"
        ],
        "type": "object",
        "properties": {
          "scheduleCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the schedule to link the client to. Schedules are created and managed task-side."
          }
        },
        "additionalProperties": false,
        "description": "Links one client to an existing schedule on a recurring task. The client and task come from\nthe route; reverting to the default schedule is the DELETE on the same route."
      },
      "AssignmentType": {
        "enum": [
          "Unassigned",
          "SpecificUser",
          "ClientManager",
          "ClientServiceManager",
          "ClientPartner",
          "ClientAssociate",
          "ClientServicePreparer",
          "ClientServiceReviewer"
        ],
        "type": "string",
        "example": "Unassigned"
      },
      "AuditUserType": {
        "enum": [
          "System",
          "User",
          "Portal",
          "MagicLink"
        ],
        "type": "string",
        "example": "System"
      },
      "AuthCodeEntrySource": {
        "enum": [
          "None",
          "Practice",
          "Client"
        ],
        "type": "string",
        "example": "None"
      },
      "AuthProviderType": {
        "enum": [
          "Local",
          "Auth0",
          "Google",
          "Facebook",
          "Xero",
          "Microsoft"
        ],
        "type": "string",
        "description": "Defines the authentication provider type for a user.",
        "example": "Local"
      },
      "AuthenticationType": {
        "enum": [
          "OAuth",
          "ApiKey",
          "Basic",
          "OAuthClientCredentials"
        ],
        "type": "string",
        "example": "OAuth"
      },
      "AvailableBookkeepingOrganisationDto": {
        "type": "object",
        "properties": {
          "organisation": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "An organisation that could be linked to a client, read live from the bookkeeping-health\nprovider."
      },
      "AvailableBooksOrganisationDto": {
        "type": "object",
        "properties": {
          "organisation": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "connection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "platform": {
            "type": "string",
            "description": "The accounting platform the organisation lives on.",
            "nullable": true
          },
          "unavailableReason": {
            "type": "string",
            "description": "Why this organisation cannot be chosen for the client (it is the practice's own books, or it is\nalready linked to another client), or null when it can.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An organisation that could be linked to a client, read live from the accounting platform."
      },
      "AvailableClientDto": {
        "type": "object",
        "properties": {
          "externalId": {
            "type": "string",
            "description": "Platform-specific customer identifier (used to perform the import)",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Customer/company name from the accounting platform",
            "nullable": true
          },
          "code": {
            "type": "string",
            "description": "Customer code/reference from the accounting platform (if available)",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "Primary email address",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "description": "Primary phone number",
            "nullable": true
          },
          "address": {
            "type": "string",
            "description": "Street address",
            "nullable": true
          },
          "city": {
            "type": "string",
            "description": "City/town",
            "nullable": true
          },
          "postalCode": {
            "type": "string",
            "description": "Postal/ZIP code",
            "nullable": true
          },
          "country": {
            "type": "string",
            "description": "Country",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the customer is active in the accounting platform"
          },
          "contactCount": {
            "type": "integer",
            "description": "Number of contacts associated with this customer in the accounting platform",
            "format": "int32"
          },
          "companyNumber": {
            "type": "string",
            "description": "Company registration number as the platform holds it. Null when the platform's list gives none.",
            "nullable": true
          },
          "importedAs": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "isLinked": {
            "type": "boolean",
            "description": "Whether the Sodium client in SodiumHQ.DTOs.ClientImport.AvailableClientDto.ImportedAs was an existing client linked by hand rather than one\nthe import created. False when not imported."
          },
          "suggestedMatch": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "A customer/client retrieved from a third-party accounting platform (Xero, QuickBooks, FreeAgent, etc.)\nthat is available to be imported into Sodium as a client.\nShows the platform's data and indicates whether it has already been imported."
      },
      "AvailableClientDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AvailableClientDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "BackgroundImageDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for this background image.",
            "nullable": true
          },
          "imageAsset": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "pageSelection": {
            "$ref": "#/components/schemas/PageSelection"
          },
          "position": {
            "$ref": "#/components/schemas/BackgroundImagePosition"
          },
          "offsetXMm": {
            "type": "number",
            "description": "Horizontal offset in mm from the left edge. Only used when Position is Custom.",
            "format": "float"
          },
          "offsetYMm": {
            "type": "number",
            "description": "Vertical offset in mm from the top edge. Only used when Position is Custom.",
            "format": "float"
          },
          "widthMm": {
            "type": "number",
            "description": "Width in millimeters. Null means natural width or full page for FullPage position.",
            "format": "float",
            "nullable": true
          },
          "heightMm": {
            "type": "number",
            "description": "Height in millimeters. Null means natural height or full page for FullPage position.",
            "format": "float",
            "nullable": true
          },
          "opacity": {
            "type": "number",
            "description": "Opacity from 0.0 (transparent) to 1.0 (opaque). Useful for watermark effects.",
            "format": "float"
          },
          "overlayColor": {
            "type": "string",
            "description": "Optional overlay color in hex format. Applied with mix-blend-mode: multiply for a tint effect.",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Rendering order (z-index). Lower values render behind higher values.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A background image configured on a design theme for PDF rendering."
      },
      "BackgroundImagePosition": {
        "enum": [
          "FullPage",
          "TopCenter",
          "BottomCenter",
          "Center",
          "TopLeft",
          "TopRight",
          "BottomLeft",
          "BottomRight",
          "Custom"
        ],
        "type": "string",
        "example": "FullPage"
      },
      "BackgroundImageRequest": {
        "required": [
          "imageAssetCode"
        ],
        "type": "object",
        "properties": {
          "imageAssetCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the image asset from the media library."
          },
          "pageSelection": {
            "$ref": "#/components/schemas/PageSelection"
          },
          "position": {
            "$ref": "#/components/schemas/BackgroundImagePosition"
          },
          "offsetXMm": {
            "maximum": 297,
            "minimum": 0,
            "type": "number",
            "description": "Horizontal offset in mm from the left edge. Only used when Position is Custom.",
            "format": "float"
          },
          "offsetYMm": {
            "maximum": 420,
            "minimum": 0,
            "type": "number",
            "description": "Vertical offset in mm from the top edge. Only used when Position is Custom.",
            "format": "float"
          },
          "widthMm": {
            "maximum": 297,
            "minimum": 1,
            "type": "number",
            "description": "Width in millimeters. Null means natural width or full page for FullPage position.",
            "format": "float",
            "nullable": true
          },
          "heightMm": {
            "maximum": 420,
            "minimum": 1,
            "type": "number",
            "description": "Height in millimeters. Null means natural height or full page for FullPage position.",
            "format": "float",
            "nullable": true
          },
          "opacity": {
            "maximum": 1,
            "minimum": 0,
            "type": "number",
            "description": "Opacity from 0.0 (transparent) to 1.0 (opaque). Useful for watermark effects.",
            "format": "float"
          },
          "overlayColor": {
            "maxLength": 10,
            "type": "string",
            "description": "Optional overlay color in hex format. Applied with mix-blend-mode: multiply for a tint effect.",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Rendering order (z-index). Lower values render behind higher values.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating or updating a background image on a design theme."
      },
      "BankBalanceStatus": {
        "enum": [
          "NotReported",
          "Reported",
          "Failed"
        ],
        "type": "string",
        "example": "NotReported"
      },
      "BankHolidayDto": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "The date of the bank holiday",
            "format": "date"
          },
          "name": {
            "type": "string",
            "description": "Name of the bank holiday (e.g., \"Good Friday\", \"Christmas Day\")",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Bank holiday information"
      },
      "BankHolidayRegion": {
        "enum": [
          "None",
          "England",
          "Wales",
          "Scotland",
          "NorthernIreland"
        ],
        "type": "string",
        "example": "None"
      },
      "BankTransactionsSupport": {
        "enum": [
          "None",
          "Available",
          "NotPermitted"
        ],
        "type": "string",
        "example": "None"
      },
      "BenefitsInKind": {
        "type": "object",
        "properties": {
          "accommodation": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "assets": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "assetTransfer": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "beneficialLoan": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "car": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "carFuel": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "educationalServices": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "entertaining": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "expenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "medicalInsurance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "telephone": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "service": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxableExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "van": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "vanFuel": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "mileage": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "nonQualifyingRelocationExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "nurseryPlaces": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherItems": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "paymentsOnEmployeesBehalf": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "personalIncidentalExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "qualifyingRelocationExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "employerProvidedProfessionalSubscriptions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "employerProvidedServices": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "incomeTaxPaidByDirector": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "travelAndSubsistence": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "vouchersAndCreditCards": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "nonCash": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BillClientTimeResultDto": {
        "type": "object",
        "properties": {
          "client": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "lineItemCount": {
            "type": "integer",
            "description": "Billing line items created for this client",
            "format": "int32"
          },
          "entryCount": {
            "type": "integer",
            "description": "Time entries marked as billed for this client",
            "format": "int32"
          },
          "amount": {
            "type": "number",
            "description": "Total value of the created line items, excluding VAT",
            "format": "double"
          },
          "skippedUnratedCount": {
            "type": "integer",
            "description": "Entries left unbilled because they have no hourly rate. They stay unbilled and will\nreappear in the unbilled list once a rate is set.",
            "format": "int32"
          },
          "error": {
            "type": "string",
            "description": "Why nothing was billed for this client, when the attempt failed. Null on success.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What happened to one client in a bulk time-billing run. Clients are billed independently,\nso a run can succeed for some and fail for others — read every row, not just the first.\nA row with no line items and no error means the client had nothing to bill in the window."
      },
      "BillClientsTimeRequest": {
        "required": [
          "clientCodes"
        ],
        "type": "object",
        "properties": {
          "clientCodes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the clients whose unbilled time should be billed"
          },
          "fromDate": {
            "type": "string",
            "description": "Only bill entries on or after this date. Unbounded when omitted.",
            "format": "date",
            "nullable": true
          },
          "toDate": {
            "type": "string",
            "description": "Only bill entries on or before this date. Unbounded when omitted.",
            "format": "date",
            "nullable": true
          },
          "userCode": {
            "type": "string",
            "description": "Only bill entries recorded by this team member. All team members when omitted.",
            "nullable": true
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "The invoice line description. Defaults to a summary of each client's billed period when omitted.",
            "nullable": true
          },
          "billingDate": {
            "type": "string",
            "description": "Target invoice date. Defaults to today when omitted.",
            "format": "date-time",
            "nullable": true
          },
          "accountingCode": {
            "maxLength": 20,
            "type": "string",
            "description": "Accounting/nominal code. Defaults from the client billing settings when omitted.",
            "nullable": true
          },
          "lineMode": {
            "$ref": "#/components/schemas/TimeBillingLineMode"
          },
          "clientFees": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientFeeRequest"
            },
            "description": "A fee per client, for clients that should be charged something other than their open WIP.\nClients not listed are billed at their full open WIP.",
            "nullable": true
          },
          "remainderHandling": {
            "$ref": "#/components/schemas/WipRemainderHandling"
          },
          "writeOffReasonCode": {
            "type": "string",
            "description": "The write-off reason applied to every client whose fee writes time off or on. Required\nwhen any listed fee differs from that client's open WIP.",
            "nullable": true
          },
          "notes": {
            "maxLength": 500,
            "type": "string",
            "description": "Free-text context recorded on each allocation",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to bill several clients' unbilled time in one run — the whole-book equivalent of\nbilling a single client's hand-picked entries. The server resolves which entries to bill\nfrom the same window and team member filters the unbilled list was viewed under, so the\ncaller doesn't have to enumerate entry codes for every client.\nEntries with no hourly rate cannot be billed and are skipped rather than failing the run.\nThere is no VAT rate to pass: each client is billed at its own treatment, so a run\ncovering a mix of UK and outside-the-scope clients still invoices each of them correctly."
      },
      "BillForWorkAmountSource": {
        "enum": [
          "ServicePrice",
          "FixedAmount"
        ],
        "type": "string",
        "example": "ServicePrice"
      },
      "BillForWorkExecutionStateDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client the line was raised for",
            "nullable": true
          },
          "scheduleItemCode": {
            "type": "string",
            "description": "The billing schedule item the step placed and billed",
            "nullable": true
          },
          "lineItemCode": {
            "type": "string",
            "description": "The billing line item created",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "description": "The line's amount ex VAT when it was created",
            "format": "double"
          },
          "lineStatus": {
            "$ref": "#/components/schemas/ClientBillingLineItemStatus"
          },
          "invoiceNote": {
            "type": "string",
            "description": "Why the line was not invoiced although the step asked for it. Null when it was invoiced or was\nnot asked to be.",
            "nullable": true
          },
          "billedAt": {
            "type": "string",
            "description": "UTC time the line was created",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "What a BillForWork step billed. Read-only: written by the system when the step runs."
      },
      "BillForWorkPreviewDto": {
        "type": "object",
        "properties": {
          "amount": {
            "type": "number",
            "description": "What the line will come to, excluding VAT. Null when the step cannot bill.",
            "format": "double",
            "nullable": true
          },
          "isEstimate": {
            "type": "boolean",
            "description": "True when the amount rests on a per-unit quantity that varies each period: the line is left\nPending for a person to confirm the quantity."
          },
          "periodStart": {
            "type": "string",
            "description": "First day of the service period billed. Null for a fixed amount, which is an ad hoc charge.",
            "format": "date",
            "nullable": true
          },
          "periodEnd": {
            "type": "string",
            "description": "Last day of the service period billed. Null for a fixed amount.",
            "format": "date",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The line description, tokens rendered. Null when the step sets none and the service's own\nline description (or the ad hoc fallback) applies.",
            "nullable": true
          },
          "problem": {
            "type": "string",
            "description": "Why the step cannot bill as configured (the service bills on its schedule, the period is\nalready billed, the task has no service). Null when it can.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a Bill for Work step will bill if it runs now, worked out the way the step itself works it\nout, or why it cannot bill."
      },
      "BillForWorkStepConfigDto": {
        "type": "object",
        "properties": {
          "amountSource": {
            "$ref": "#/components/schemas/BillForWorkAmountSource"
          },
          "fixedAmount": {
            "maximum": 100000000,
            "minimum": 0.01,
            "type": "number",
            "description": "The amount billed (ex VAT) when AmountSource is FixedAmount. Required then; ignored otherwise.",
            "format": "double",
            "nullable": true
          },
          "lineDescription": {
            "maxLength": 500,
            "type": "string",
            "description": "The billing line description. Supports template tokens (e.g. {{ Client.Name }},\n{{ Task.DueDate }}). Blank uses the service's own line description.",
            "nullable": true
          },
          "accountingCode": {
            "maxLength": 20,
            "type": "string",
            "description": "The accounting (nominal) code for the line. Blank uses the service's, or the practice default.",
            "nullable": true
          },
          "invoiceImmediately": {
            "type": "boolean",
            "description": "Invoice the line as soon as it is created, bypassing the practice's approval setting. A per-unit\nline whose quantity is still a guess is left pending to confirm."
          }
        },
        "additionalProperties": false,
        "description": "Configuration for BillForWork workflow steps: bills the client when the work is done, from the\ntask's service price or a fixed amount, and optionally invoices it straight away."
      },
      "BillTimeEntriesRequest": {
        "required": [
          "timeEntryCodes"
        ],
        "type": "object",
        "properties": {
          "timeEntryCodes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the time entries to bill"
          },
          "vatRate": {
            "$ref": "#/components/schemas/VatRate"
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "The invoice line description. Defaults to a summary of the billed period when omitted.",
            "nullable": true
          },
          "billingDate": {
            "type": "string",
            "description": "Target invoice date. Defaults to today when omitted.",
            "format": "date-time",
            "nullable": true
          },
          "accountingCode": {
            "maxLength": 20,
            "type": "string",
            "description": "Accounting/nominal code. Defaults from the client billing settings when omitted.",
            "nullable": true
          },
          "lineMode": {
            "$ref": "#/components/schemas/TimeBillingLineMode"
          },
          "feeAmount": {
            "maximum": 100000000,
            "minimum": 0.01,
            "type": "number",
            "description": "The total to charge (ex VAT) for the selected entries. Omitted, the entries are billed at\ntheir full billable value. Below the open WIP, the shortfall is written off or left open per\nRemainderHandling; above it, the excess is a write-on. Must be greater than zero.",
            "format": "double",
            "nullable": true
          },
          "remainderHandling": {
            "$ref": "#/components/schemas/WipRemainderHandling"
          },
          "allocations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimeEntryAllocationRequest"
            },
            "description": "Explicit per-entry allocations for the cherry-picking case. When supplied, every selected\nentry needs one, the billed amounts must sum to FeeAmount if that is given too, and\nRemainderHandling is ignored.",
            "nullable": true
          },
          "writeOffReasonCode": {
            "type": "string",
            "description": "The code of the write-off reason. Required when the run writes time off or on; ignored\nwhen it does not.",
            "nullable": true
          },
          "notes": {
            "maxLength": 500,
            "type": "string",
            "description": "Free-text context recorded on each allocation",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to convert billable time entries with open WIP into client billing line items.\nAll entries must belong to the same client, be billable, carry an hourly rate and have WIP\nleft to bill. Line items are shaped by the line mode: combined (one per distinct hourly rate)\nor one per entry. With no fee the entries are billed at their full billable value, as always. With\na fee, the fee is what the client is charged: it is spread across the entries pro rata to their\nopen WIP, and the difference between the WIP and the fee is a write-off (or write-on) that\nneeds a reason."
      },
      "BillableServiceDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "isArchived": {
            "type": "boolean",
            "description": "Indicates whether this service is archived (inactive)"
          },
          "accountingCode": {
            "type": "string",
            "description": "The accounting code for this service",
            "nullable": true
          },
          "defaultManagedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "serviceScheduleContent": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "proposalContent": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "category": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "vatRate": {
            "$ref": "#/components/schemas/VatRate"
          },
          "pricingMode": {
            "$ref": "#/components/schemas/ServicePricingMode"
          },
          "pricingTiers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServicePricingTierDto"
            },
            "description": "Custom pricing tiers defined on this service. Only populated when PricingMode = CustomTiers.",
            "nullable": true
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServiceStageDto"
            },
            "description": "User-defined workflow stages for this service",
            "nullable": true
          },
          "clientTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "The types of clients this service is applicable to.\nAn empty list means the service is applicable to all client types.",
            "nullable": true
          },
          "agentAuthorisations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentAuthorisationType"
            },
            "description": "The HMRC agent authorisation types relevant to this service",
            "nullable": true
          },
          "requiredProducts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SodiumProduct"
            },
            "description": "The Sodium products this service is powered by. A client taking the service gets each\nproduct's tab on their record.",
            "nullable": true
          },
          "pricing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServicePricingOptionDto"
            },
            "description": "The pricing options available for this service\nPrice changes will automatically cascade to all ClientBillableService records using this BillableService\n(unless OverridePricing is set on the ClientBillableService), but any PriceAdjustmentPercentage will still be applied",
            "nullable": true
          },
          "pricingFactors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PricingFactorDto"
            },
            "description": "The pricing factors that can affect the service pricing calculations",
            "nullable": true
          },
          "pcrItems": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Professional clearance request items for this service",
            "nullable": true
          },
          "packages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The unarchived service packages that include this service. Read-only.",
            "nullable": true
          },
          "showKanbanBoard": {
            "type": "boolean",
            "description": "Whether this service should appear on the Boards kanban view"
          },
          "stageCount": {
            "type": "integer",
            "description": "The number of stages defined on this service",
            "format": "int32"
          },
          "recurringTaskCount": {
            "type": "integer",
            "description": "The number of recurring tasks associated with this service",
            "format": "int32"
          },
          "recurringTasksWithoutWorkflowCount": {
            "type": "integer",
            "description": "How many of this service's recurring tasks have no workflow attached. Read-only.",
            "format": "int32"
          },
          "activeRecurringTaskCount": {
            "type": "integer",
            "description": "How many of this service's recurring tasks are switched on. Read-only.",
            "format": "int32"
          },
          "activeOnboardingTaskCount": {
            "type": "integer",
            "description": "How many of this service's onboarding tasks are switched on. Read-only.",
            "format": "int32"
          },
          "clientCount": {
            "type": "integer",
            "description": "How many clients have this service on their record, whatever its status. Read-only.",
            "format": "int32"
          },
          "activeClientCount": {
            "type": "integer",
            "description": "How many clients have this service Active. A client with the service more than once counts once,\nunder its most live status (Active, then Paused, Proposed, Inactive). Read-only.",
            "format": "int32"
          },
          "pausedClientCount": {
            "type": "integer",
            "description": "How many clients have this service Paused. Read-only.",
            "format": "int32"
          },
          "proposedClientCount": {
            "type": "integer",
            "description": "How many clients have this service Proposed. Read-only.",
            "format": "int32"
          },
          "inactiveClientCount": {
            "type": "integer",
            "description": "How many clients have this service Inactive. Read-only.",
            "format": "int32"
          },
          "invoiceLineDescriptionTemplate": {
            "type": "string",
            "description": "Smart name token template for invoice line descriptions",
            "nullable": true
          },
          "setupFee": {
            "type": "number",
            "description": "Optional one-off setup fee charged when the service is first billed for a client.\nNull means no setup fee. Used as the default when assigning the service to a client.",
            "format": "double",
            "nullable": true
          },
          "pricingBasis": {
            "$ref": "#/components/schemas/PricingBasis"
          },
          "unitName": {
            "type": "string",
            "description": "The unit label for PerUnit pricing (e.g. \"employee\", \"timesheet\"). Only set when PricingBasis is PerUnit.",
            "nullable": true
          },
          "quantityVariesPerPeriod": {
            "type": "boolean",
            "description": "Whether the billed quantity is expected to change from period to period. When true (default),\ngenerated billing lines for non-Fixed services are always created Pending so the quantity can be\nconfirmed before invoicing, regardless of the approval settings. Used as the default when\nassigning the service to a client. Ignored when PricingBasis is Fixed."
          },
          "defaultUnitQuantity": {
            "type": "number",
            "description": "The typical quantity per billing period, used as the default when assigning the service to a\nclient. Null means the volume is unknown. Ignored when PricingBasis is Fixed.",
            "format": "double",
            "nullable": true
          },
          "supportsCatchUpFees": {
            "type": "boolean",
            "description": "Whether a catch-up fee can be agreed when this service is assigned to a client. On by\ndefault; switch it off for services where catching up on backlog makes no sense."
          },
          "billingTiming": {
            "$ref": "#/components/schemas/BillingTiming"
          },
          "compoundPercentageFactors": {
            "type": "boolean",
            "description": "Whether percentage pricing factors compound (+20% and +10% is +32%) rather than\nadd (+30%). Fixed-amount factors are added afterwards either way."
          },
          "hasPreparerRole": {
            "type": "boolean",
            "description": "Whether clients on this service have a Preparer"
          },
          "defaultPreparerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "hasReviewerRole": {
            "type": "boolean",
            "description": "Whether clients on this service have a Reviewer"
          },
          "defaultReviewerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When the service was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the service was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for billable service information"
      },
      "BillableServiceDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServiceDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "BillableServicePricingOptionDto": {
        "type": "object",
        "properties": {
          "frequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "price": {
            "type": "number",
            "description": "The default price for this billing frequency\nPrice changes will automatically cascade to all ClientBillableService records using this BillableService\n(unless OverridePricing is set on the ClientBillableService, but any PriceAdjustmentPercentage will still be applied)",
            "format": "double"
          },
          "revenueRangeOverrides": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServicePricingOverrideDto"
            },
            "description": "Revenue range-specific pricing overrides",
            "nullable": true
          },
          "tierOverrides": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServicePricingTierOverrideDto"
            },
            "description": "Custom tier-specific pricing overrides. Only used when parent BillableService has PricingMode = CustomTiers.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for billable service pricing option information"
      },
      "BillableServicePricingOverrideDto": {
        "type": "object",
        "properties": {
          "revenueRangeCode": {
            "type": "string",
            "description": "The revenue range code this override applies to",
            "nullable": true
          },
          "overridePrice": {
            "type": "number",
            "description": "The override price for this revenue range (null to use default price)",
            "format": "double",
            "nullable": true
          },
          "overrideDescription": {
            "type": "string",
            "description": "The override description for this revenue range (null to use default description)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for revenue range-specific pricing overrides"
      },
      "BillableServicePricingTierDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this tier",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The name of the tier (e.g. \"1-10 payslips\")",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The display order for this tier",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "DTO for a custom pricing tier defined on a billable service"
      },
      "BillableServicePricingTierOverrideDto": {
        "type": "object",
        "properties": {
          "tierCode": {
            "type": "string",
            "description": "The code of the pricing tier this override applies to",
            "nullable": true
          },
          "overridePrice": {
            "type": "number",
            "description": "The override price for this tier (null to use default price)",
            "format": "double",
            "nullable": true
          },
          "overrideDescription": {
            "type": "string",
            "description": "The override description for this tier (null to use default description)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for a custom tier-specific pricing override"
      },
      "BillableServiceSortField": {
        "enum": [
          "Name",
          "Category",
          "AccountingCode"
        ],
        "type": "string",
        "example": "Name"
      },
      "BillableServiceStageDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this stage",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of this stage",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional description of what this stage represents",
            "nullable": true
          },
          "icon": {
            "type": "string",
            "description": "Optional Lucide icon name for visual identification",
            "nullable": true
          },
          "color": {
            "type": "string",
            "description": "Optional hex colour for visual identification",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The display order for this stage",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "DTO for a user-defined workflow stage on a billable service"
      },
      "BillingAccountResponse": {
        "required": [
          "billingContactUserCode",
          "code",
          "name"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code identifier for the billing account.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the billing account.",
            "nullable": true
          },
          "billingContactUserCode": {
            "type": "string",
            "description": "The code of the user responsible for billing.",
            "nullable": true
          },
          "billingContactName": {
            "type": "string",
            "description": "The display name of the billing contact.",
            "nullable": true
          },
          "billingContactEmail": {
            "type": "string",
            "description": "The email address of the billing contact.",
            "nullable": true
          },
          "billingDay": {
            "type": "integer",
            "description": "The day of the month (1-28) when invoices are generated.",
            "format": "int32"
          },
          "status": {
            "$ref": "#/components/schemas/BillingAccountStatus"
          },
          "mandate": {
            "$ref": "#/components/schemas/MandateSummaryResponse"
          },
          "additionalInvoiceRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceRecipient"
            },
            "description": "Additional recipients who receive invoices.\nThe billing contact's email is always included automatically.",
            "nullable": true
          },
          "billingAddress": {
            "$ref": "#/components/schemas/BillingAddress"
          },
          "linkedTenants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The tenants linked to this billing account.",
            "nullable": true
          },
          "accountingCustomer": {
            "$ref": "#/components/schemas/AccountingLinkResponse"
          },
          "vatTreatment": {
            "$ref": "#/components/schemas/VatTreatment"
          },
          "vatNumber": {
            "type": "string",
            "description": "The customer's VAT registration number, printed on their invoices.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "The date and time when the billing account was created.",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "The date and time when the billing account was last updated.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model representing a billing account."
      },
      "BillingAccountStatus": {
        "enum": [
          "MandateRequired",
          "Active",
          "Suspended",
          "Closed"
        ],
        "type": "string",
        "description": "Defines the status of a billing account.",
        "example": "MandateRequired"
      },
      "BillingAddress": {
        "type": "object",
        "properties": {
          "companyName": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The company name.",
            "nullable": true
          },
          "addressLine1": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The first line of the address.",
            "nullable": true
          },
          "addressLine2": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The second line of the address.",
            "nullable": true
          },
          "city": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The city.",
            "nullable": true
          },
          "postalCode": {
            "maxLength": 20,
            "minLength": 0,
            "type": "string",
            "description": "The postal code.",
            "nullable": true
          },
          "country": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The country.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents a billing address."
      },
      "BillingFrequency": {
        "enum": [
          "OneOff",
          "Annual",
          "Quarterly",
          "Monthly",
          "Weekly"
        ],
        "type": "string",
        "example": "OneOff"
      },
      "BillingInvoiceStatus": {
        "enum": [
          "Draft",
          "Issued",
          "PaymentPending",
          "Paid",
          "PaymentFailed",
          "Cancelled",
          "Uncollected"
        ],
        "type": "string",
        "description": "Defines the status of a billing invoice.",
        "example": "Draft"
      },
      "BillingScheduleDisplayStatus": {
        "enum": [
          "Scheduled",
          "Overdue",
          "Pending",
          "Approved",
          "Invoiced",
          "Cancelled",
          "Skipped"
        ],
        "type": "string",
        "example": "Scheduled"
      },
      "BillingScheduleItemKind": {
        "enum": [
          "Recurring",
          "SetupFee",
          "CatchUp",
          "AdHoc"
        ],
        "type": "string",
        "example": "Recurring"
      },
      "BillingScheduleItemStatus": {
        "enum": [
          "Scheduled",
          "Billed",
          "Skipped"
        ],
        "type": "string",
        "example": "Scheduled"
      },
      "BillingScheduleMonthTotalDto": {
        "type": "object",
        "properties": {
          "year": {
            "type": "integer",
            "description": "The calendar year",
            "format": "int32"
          },
          "month": {
            "type": "integer",
            "description": "The calendar month (1-12)",
            "format": "int32"
          },
          "itemCount": {
            "type": "integer",
            "description": "Number of scheduled items billing in the month",
            "format": "int32"
          },
          "total": {
            "type": "number",
            "description": "Sum of the scheduled items' amounts (quantity × unit price, before VAT)",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Planned billing for one calendar month across the practice: what the schedule expects to\npromote, at today's prices."
      },
      "BillingTiming": {
        "enum": [
          "InArrears",
          "InAdvance",
          "OnCompletion"
        ],
        "type": "string",
        "example": "InArrears"
      },
      "BookkeepingActivityPeriodDto": {
        "type": "object",
        "properties": {
          "duration": {
            "type": "string",
            "description": "The provider's name for the time bucket — the join key against the quality buckets.",
            "nullable": true
          },
          "turnover": {
            "type": "number",
            "description": "Net turnover movement for the bucket. Can be negative — it is a net movement, not \"sales\" —\nso colour by sign rather than assuming it is positive.",
            "format": "double"
          },
          "transactionCount": {
            "type": "integer",
            "description": "Total transactions in the bucket.",
            "format": "int32"
          },
          "invoices": {
            "type": "integer",
            "format": "int32"
          },
          "bills": {
            "type": "integer",
            "format": "int32"
          },
          "creditNotes": {
            "type": "integer",
            "format": "int32"
          },
          "journals": {
            "type": "integer",
            "format": "int32"
          },
          "bankTransactions": {
            "type": "integer",
            "description": "Bank transactions in the bucket.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The provider's activity figures over one time bucket."
      },
      "BookkeepingHealthDto": {
        "type": "object",
        "properties": {
          "organisationName": {
            "type": "string",
            "description": "The linked organisation's name.",
            "nullable": true
          },
          "retrievedAt": {
            "type": "string",
            "description": "When the figures were fetched from the provider. Server-side caching means this can be up to\nten minutes ago — show it so nobody reads the numbers as live.",
            "format": "date-time"
          },
          "quality": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BookkeepingQualityPeriodDto"
            },
            "description": "Quality scoring per time bucket, in the provider's order.",
            "nullable": true
          },
          "activity": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BookkeepingActivityPeriodDto"
            },
            "description": "Activity figures per time bucket, in the provider's order. Not the same bucket set as\nSodiumHQ.DTOs.BookkeepingHealth.BookkeepingHealthDto.Quality — join by duration and expect gaps.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Everything the bookkeeping-health provider reports about a client's books — quality and\nactivity, every time bucket the provider returned. The bucket selector in the UI switches\nbetween buckets client-side; nothing here is windowed."
      },
      "BookkeepingQualityPeriodDto": {
        "type": "object",
        "properties": {
          "duration": {
            "type": "string",
            "description": "The provider's name for the time bucket (e.g. \"current\", \"previous_month\",\n\"rolling_12_months\"). A plain string — the set varies per organisation and new buckets\nappear without notice, so render whatever arrives.",
            "nullable": true
          },
          "healthIndicator": {
            "type": "integer",
            "description": "The provider's own health score as a percentage. Display it verbatim — it does not track the\nissue count and must never be recomputed from it.",
            "format": "int32"
          },
          "totalIssues": {
            "type": "integer",
            "description": "How many bookkeeping issues the provider found in the bucket.",
            "format": "int32"
          },
          "potentialErrors": {
            "type": "number",
            "description": "The monetary value at risk from those issues — format as currency, not a count.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "The provider's quality scoring over one time bucket."
      },
      "BooksAgeingContactDto": {
        "type": "object",
        "properties": {
          "current": {
            "type": "number",
            "description": "Not yet due: due today or later.",
            "format": "double"
          },
          "days1To30": {
            "type": "number",
            "description": "1 to 30 days past due.",
            "format": "double"
          },
          "days31To60": {
            "type": "number",
            "description": "31 to 60 days past due.",
            "format": "double"
          },
          "days61To90": {
            "type": "number",
            "description": "61 to 90 days past due.",
            "format": "double"
          },
          "over90Days": {
            "type": "number",
            "description": "More than 90 days past due.",
            "format": "double"
          },
          "overdue": {
            "type": "number",
            "description": "Everything past due: the four overdue buckets together.",
            "format": "double"
          },
          "total": {
            "type": "number",
            "description": "Everything outstanding: current plus overdue.",
            "format": "double"
          },
          "documentCount": {
            "type": "integer",
            "description": "How many invoices or bills make up these amounts.",
            "format": "int32"
          },
          "contactId": {
            "type": "string",
            "description": "The platform's identifier for the contact, or null for documents raised against none.",
            "nullable": true
          },
          "contactName": {
            "type": "string",
            "description": "The contact's name as the documents carry it, or null where the platform gave none.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One customer's or supplier's share of an ageing side."
      },
      "BooksAgeingDto": {
        "type": "object",
        "properties": {
          "asAt": {
            "type": "string",
            "description": "The day everything was aged to (today, in UTC).",
            "format": "date"
          },
          "receivables": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksAgeingSideDto"
            },
            "description": "Debtors: outstanding sales invoices, one entry per currency, largest total first. Empty when\nnobody owes the client anything.",
            "nullable": true
          },
          "payables": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksAgeingSideDto"
            },
            "description": "Creditors: outstanding bills, one entry per currency, largest total first. Empty when the\nclient owes nothing.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client's debtors and creditors as at one day: what customers owe the client (receivables) and\nwhat the client owes suppliers (payables), aged by days past due.\n            \nWorked out by Sodium from the outstanding sales invoices and bills, so it has the same shape on\nevery platform. Credit notes and unallocated payments are not netted off, so it can differ from\nthe platform's own aged reports."
      },
      "BooksAgeingSideDto": {
        "type": "object",
        "properties": {
          "current": {
            "type": "number",
            "description": "Not yet due: due today or later.",
            "format": "double"
          },
          "days1To30": {
            "type": "number",
            "description": "1 to 30 days past due.",
            "format": "double"
          },
          "days31To60": {
            "type": "number",
            "description": "31 to 60 days past due.",
            "format": "double"
          },
          "days61To90": {
            "type": "number",
            "description": "61 to 90 days past due.",
            "format": "double"
          },
          "over90Days": {
            "type": "number",
            "description": "More than 90 days past due.",
            "format": "double"
          },
          "overdue": {
            "type": "number",
            "description": "Everything past due: the four overdue buckets together.",
            "format": "double"
          },
          "total": {
            "type": "number",
            "description": "Everything outstanding: current plus overdue.",
            "format": "double"
          },
          "documentCount": {
            "type": "integer",
            "description": "How many invoices or bills make up these amounts.",
            "format": "int32"
          },
          "currency": {
            "type": "string",
            "description": "ISO currency code of every amount on this side, or null where the platform named none.",
            "nullable": true
          },
          "contacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksAgeingContactDto"
            },
            "description": "The same amounts by customer (receivables) or supplier (payables), largest total first.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One side of the ageing in one currency. Split by currency rather than converted, so amounts in\ndifferent currencies are never added together."
      },
      "BooksBalanceSheetDto": {
        "type": "object",
        "properties": {
          "asAt": {
            "type": "string",
            "description": "The date the figures are stated as at — the date the platform ran the report to, which is\nnot always the date asked for (Xero serves a mid-month date as at that month's end).",
            "format": "date"
          },
          "currency": {
            "type": "string",
            "description": "ISO currency code the figures are in, where the platform reports one.",
            "nullable": true
          },
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksReportSectionDto"
            },
            "description": "The report's sections in the order the platform returned them, deliberately not normalised\ninto fixed totals. A section with a title and no lines is a heading the platform emitted.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A balance sheet over a client's own books, as at one date."
      },
      "BooksBankAccountDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The platform's identifier for the account.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The account's name in the books.",
            "nullable": true
          },
          "accountNumber": {
            "type": "string",
            "description": "The account number, where the platform exposes it — often partially masked.",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "description": "ISO currency code, where the platform reports one.",
            "nullable": true
          },
          "balance": {
            "type": "number",
            "description": "The balance the books hold, set only when SodiumHQ.DTOs.ClientBooks.BooksBankAccountDto.BalanceStatus is Reported. Null must\nnever be rendered as zero.",
            "format": "double",
            "nullable": true
          },
          "balanceStatus": {
            "$ref": "#/components/schemas/BankBalanceStatus"
          },
          "balanceCurrency": {
            "type": "string",
            "description": "ISO currency code the balance is stated in, or null when it is the account's own\nSodiumHQ.DTOs.ClientBooks.BooksBankAccountDto.Currency. Set where the platform reports balances in the organisation's base\ncurrency (Xero), so a foreign-currency account's balance is not labelled with the wrong code.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A bank account held in a client's own books."
      },
      "BooksBankTransactionDto": {
        "type": "object",
        "properties": {
          "externalId": {
            "type": "string",
            "description": "Opaque and stable id for the line: store it as the item's externalId, and compare it with the\nitems already on a request to mark lines already added.",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "The day the line is dated on.",
            "format": "date"
          },
          "description": {
            "type": "string",
            "description": "The statement line; the payee where the platform gives no description.",
            "nullable": true
          },
          "reference": {
            "type": "string",
            "description": "The platform's own reference or number for the line, where it has one.",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "description": "Signed: money into the account positive, money out negative.",
            "format": "double"
          },
          "isUnreconciled": {
            "type": "boolean",
            "description": "Whether the books have yet to explain the line, in the platform's own sense (see the\nplatform's bankTransactionsUnreconciledLabel). Null where the platform does not say on this list.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One line on a bank account in a client's books, to add to a document request as a query."
      },
      "BooksBankTransactionsDto": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "description": "First day read.",
            "format": "date"
          },
          "to": {
            "type": "string",
            "description": "Last day read.",
            "format": "date"
          },
          "currency": {
            "type": "string",
            "description": "The account's ISO currency code, where the platform reports one.",
            "nullable": true
          },
          "isTruncated": {
            "type": "boolean",
            "description": "True when the period held more than 1,000 lines and the list stops at the first 1,000."
          },
          "transactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksBankTransactionDto"
            },
            "description": "The lines, oldest first. Never null.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A bank account's lines over a period, oldest first, at most 1,000."
      },
      "BooksBillDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The platform's identifier for the bill.",
            "nullable": true
          },
          "number": {
            "type": "string",
            "description": "The supplier's own invoice number where the platform holds one, else the bill's reference.",
            "nullable": true
          },
          "supplierId": {
            "type": "string",
            "description": "The platform's identifier for the supplier.",
            "nullable": true
          },
          "supplierName": {
            "type": "string",
            "description": "The supplier's name in the client's books.",
            "nullable": true
          },
          "totalAmount": {
            "type": "number",
            "description": "Total including tax.",
            "format": "double"
          },
          "netAmount": {
            "type": "number",
            "description": "Total before tax.",
            "format": "double"
          },
          "taxAmount": {
            "type": "number",
            "description": "Tax (VAT) on the bill.",
            "format": "double"
          },
          "amountDue": {
            "type": "number",
            "description": "What the client still has to pay on the bill; less than the total once part-paid.",
            "format": "double"
          },
          "date": {
            "type": "string",
            "description": "The bill's date.",
            "format": "date-time"
          },
          "dueDate": {
            "type": "string",
            "description": "When the client has to pay it by, where the bill says.",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/InvoiceStatus"
          },
          "currency": {
            "type": "string",
            "description": "ISO currency code of the bill, where the platform reports one.",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "description": "A link to the bill in the platform's own interface, where one can be built.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A bill (purchase invoice) in a client's own books: something the client owes a supplier."
      },
      "BooksBillDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksBillDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "BooksContactDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The platform's identifier for the contact.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The contact's display name.",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phoneNumber": {
            "type": "string",
            "nullable": true
          },
          "isCustomer": {
            "type": "boolean",
            "description": "Whether the books treat this contact as someone the client sells to."
          },
          "isSupplier": {
            "type": "boolean",
            "description": "Whether the books treat this contact as someone the client buys from."
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the contact is still active in the books."
          },
          "outstandingBalance": {
            "type": "number",
            "description": "What the contact owes, where the platform reports it. Null means the platform does not\nreport a balance, not that nothing is owed.",
            "format": "double",
            "nullable": true
          },
          "payableBalance": {
            "type": "number",
            "description": "What the client owes the contact, where the platform reports it. Null means the platform does\nnot report one here, not that nothing is owed: Xero and Sage report it, QuickBooks and\nFreeAgent do not on this endpoint.",
            "format": "double",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "description": "A link to the contact in the platform's own interface, where one can be built.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A contact held in a client's own books."
      },
      "BooksContactDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksContactDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "BooksFinancialPeriod": {
        "enum": [
          "FinancialYearToDate",
          "LastFinancialYear"
        ],
        "type": "string",
        "example": "FinancialYearToDate"
      },
      "BooksOutstandingTotalsDto": {
        "type": "object",
        "properties": {
          "asAt": {
            "type": "string",
            "description": "The date the balance sheet was actually run to.",
            "format": "date"
          },
          "receivables": {
            "type": "number",
            "description": "What customers owe the client.",
            "format": "double"
          },
          "payables": {
            "type": "number",
            "description": "What the client owes suppliers.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "What customers owe a client and what the client owes suppliers, as two totals from the client's\nbalance sheet. Served where the platform's terms allow only report-level data from a client's\nbooks, in place of the invoice and bill lists and the ageing. Nets off credit notes and\nunallocated payments, as the balance sheet does. The documents behind the totals are reached\nthrough the link's own `externalUrl` (the organisation's dashboard in the platform)."
      },
      "BooksProfitAndLossDto": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "description": "First day of the reported period.",
            "format": "date"
          },
          "to": {
            "type": "string",
            "description": "Last day of the reported period.",
            "format": "date"
          },
          "currency": {
            "type": "string",
            "description": "ISO currency code the figures are in, where the platform reports one.",
            "nullable": true
          },
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksReportSectionDto"
            },
            "description": "The report's sections in the order the platform returned them. Deliberately not normalised\ninto fixed totals — every chart of accounts groups differently.",
            "nullable": true
          },
          "summary": {
            "$ref": "#/components/schemas/BooksProfitAndLossSummaryDto"
          },
          "headline": {
            "$ref": "#/components/schemas/BooksProfitAndLossHeadlineDto"
          }
        },
        "additionalProperties": false,
        "description": "A profit and loss report over a client's own books."
      },
      "BooksProfitAndLossHeadlineDto": {
        "required": [
          "profitLabel"
        ],
        "type": "object",
        "properties": {
          "income": {
            "type": "number",
            "description": "Total income for the period.",
            "format": "double"
          },
          "expenses": {
            "type": "number",
            "description": "Income less profit, so the three figures always reconcile with the report beneath them.",
            "format": "double"
          },
          "profit": {
            "type": "number",
            "description": "The report's bottom line.",
            "format": "double"
          },
          "profitLabel": {
            "minLength": 1,
            "type": "string",
            "description": "The platform's own name for the bottom line, such as Net Profit or Net Income."
          }
        },
        "additionalProperties": false,
        "description": "Income less expenses equals profit, whichever platform the figures came from."
      },
      "BooksProfitAndLossSummaryDto": {
        "type": "object",
        "properties": {
          "income": {
            "type": "number",
            "description": "Total income for the period.",
            "format": "double"
          },
          "expenses": {
            "type": "number",
            "description": "Total expenses for the period.",
            "format": "double"
          },
          "operatingProfit": {
            "type": "number",
            "description": "Income less expenses.",
            "format": "double"
          },
          "less": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksReportLineDto"
            },
            "description": "Deductions from operating profit — e.g. Corporation Tax, Dividends, Adjustments.",
            "nullable": true
          },
          "retainedProfit": {
            "type": "number",
            "description": "Operating profit less every line in SodiumHQ.DTOs.ClientBooks.BooksProfitAndLossSummaryDto.Less.",
            "format": "double"
          },
          "retainedProfitBroughtForward": {
            "type": "number",
            "description": "Retained profit carried in from prior periods, where the platform reports it.",
            "format": "double",
            "nullable": true
          },
          "retainedProfitCarriedForward": {
            "type": "number",
            "description": "Brought-forward retained profit plus this period's, where the platform reports it.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A platform-reported profit and loss summary."
      },
      "BooksReportLineDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The line's label — an account name, or the name of a subtotal.",
            "nullable": true
          },
          "nominalCode": {
            "type": "string",
            "description": "The account's nominal code, where the platform puts one on the line. Null on platforms whose\nreports carry names and figures only (Xero, QuickBooks), and on every subtotal.",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "description": "The line's value for the period.",
            "format": "double"
          },
          "isTotal": {
            "type": "boolean",
            "description": "Whether this line is a total or subtotal rather than an account. Totals must not be summed\nwith the lines around them."
          },
          "isArchived": {
            "type": "boolean",
            "description": "Whether the account behind this line is archived in the books — Xero's \"archived\",\nQuickBooks' inactive. Reports go on listing retired accounts, usually at nil, so the practice\nUI hides an archived line whose amount is zero and shows every other one. False on subtotals,\nand on platforms whose reports do not identify the account (FreeAgent, which has no archiving\nat all) — it means \"not known to be archived\", never \"known to be active\"."
          }
        },
        "additionalProperties": false,
        "description": "One line of a report."
      },
      "BooksReportPeriodDto": {
        "type": "object",
        "properties": {
          "financialPeriod": {
            "$ref": "#/components/schemas/BooksFinancialPeriod"
          },
          "dateRange": {
            "$ref": "#/components/schemas/PresetDateRange"
          },
          "from": {
            "type": "string",
            "description": "First day of the period.",
            "format": "date"
          },
          "to": {
            "type": "string",
            "description": "Last day of the period.",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "One period the books reports can be run over, with the dates it stands for today. Exactly one of\nSodiumHQ.DTOs.ClientBooks.BooksReportPeriodDto.FinancialPeriod and SodiumHQ.DTOs.ClientBooks.BooksReportPeriodDto.DateRange is set, and it is passed back as that\nsame parameter to run the report."
      },
      "BooksReportSectionDto": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "The section's heading as the platform titled it.",
            "nullable": true
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksReportLineDto"
            },
            "description": "The lines within the section, in the platform's order.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One named group of lines within a report."
      },
      "BooksTrialBalanceDto": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "description": "First day of the reported period.",
            "format": "date"
          },
          "to": {
            "type": "string",
            "description": "Last day of the reported period.",
            "format": "date"
          },
          "currency": {
            "type": "string",
            "description": "ISO currency code the figures are in, where the platform reports one.",
            "nullable": true
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BooksTrialBalanceRowDto"
            },
            "description": "The accounts, in the order the platform returned them.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A trial balance over a client's own books — one signed balance per nominal account, as the\nplatform reported it."
      },
      "BooksTrialBalanceRowDto": {
        "type": "object",
        "properties": {
          "nominalCode": {
            "type": "string",
            "description": "The account's nominal code as the platform displays it.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The account's name.",
            "nullable": true
          },
          "total": {
            "type": "number",
            "description": "The account's balance for the period — positive for debit, negative for credit.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "One account's balance on a trial balance."
      },
      "BooleanDisplayMode": {
        "enum": [
          "Toggle",
          "Checkbox",
          "YesNo"
        ],
        "type": "string",
        "example": "Toggle"
      },
      "BroadcastChannel": {
        "enum": [
          "Email",
          "Text"
        ],
        "type": "string",
        "example": "Email"
      },
      "BroadcastListItemDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The broadcast's code, unique across both kinds; open it on its kind's own routes",
            "nullable": true,
            "example": "20261113a"
          },
          "channel": {
            "$ref": "#/components/schemas/BroadcastChannel"
          },
          "title": {
            "type": "string",
            "description": "The email's subject (its content block's subject, else the block's name, when it uses one) or the text's name",
            "nullable": true,
            "example": "January self assessment reminder"
          },
          "status": {
            "$ref": "#/components/schemas/BroadcastStatus"
          },
          "total": {
            "type": "integer",
            "description": "Clients (email) or numbers (text) to send to, set when sent",
            "format": "int32",
            "example": 0
          },
          "processed": {
            "type": "integer",
            "description": "How many of them have been processed",
            "format": "int32",
            "example": 0
          },
          "failed": {
            "type": "integer",
            "description": "How many of them failed",
            "format": "int32",
            "example": 0
          },
          "createdDate": {
            "type": "string",
            "description": "When the broadcast was created (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "One bulk email or bulk text in the Bulk Comms list (docs/features/BulkTextMessages/PLAN.md, API surface)"
      },
      "BroadcastListItemDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BroadcastListItemDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "BroadcastSortField": {
        "enum": [
          "CreatedDate",
          "Status"
        ],
        "type": "string",
        "example": "CreatedDate"
      },
      "BroadcastStatus": {
        "enum": [
          "Draft",
          "Queued",
          "Sending",
          "Completed",
          "Failed",
          "Cancelled",
          "Scheduled",
          "Paused"
        ],
        "type": "string",
        "example": "Draft"
      },
      "BroughtForwardLoss": {
        "type": "object",
        "properties": {
          "lossId": {
            "type": "string",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "nullable": true
          },
          "typeOfLoss": {
            "$ref": "#/components/schemas/HmrcLossType"
          },
          "lossAmount": {
            "type": "number",
            "format": "double"
          },
          "taxYearBroughtForwardFrom": {
            "type": "string",
            "nullable": true
          },
          "lastModified": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "BsasInputs": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "nullable": true
          },
          "typeOfBusiness": {
            "type": "string",
            "nullable": true
          },
          "businessName": {
            "type": "string",
            "nullable": true
          },
          "accountingPeriodStartDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "accountingPeriodEndDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "source": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BsasMetadata": {
        "type": "object",
        "properties": {
          "calculationId": {
            "type": "string",
            "nullable": true
          },
          "requestedDateTime": {
            "type": "string",
            "format": "date-time"
          },
          "adjustedDateTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "nullable": true
          },
          "summaryStatus": {
            "$ref": "#/components/schemas/BsasSummaryStatus"
          }
        },
        "additionalProperties": false
      },
      "BsasSummaryInfo": {
        "type": "object",
        "properties": {
          "calculationId": {
            "type": "string",
            "nullable": true
          },
          "requestedDateTime": {
            "type": "string",
            "format": "date-time"
          },
          "summaryStatus": {
            "$ref": "#/components/schemas/BsasSummaryStatus"
          },
          "hasAdjustments": {
            "type": "boolean"
          },
          "adjustedDateTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BsasSummaryStatus": {
        "enum": [
          "Unknown",
          "Valid",
          "Invalid",
          "Superseded"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "BudgetBreakdownDto": {
        "type": "object",
        "properties": {
          "period": {
            "$ref": "#/components/schemas/BudgetCycleProgressDto"
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetBreakdownTaskDto"
            },
            "description": "The tasks whose time counts in the period (their intended start is in it, D2), including those with\nno time yet, by start date; then, when there is any, one row with no task code for time logged straight\nto the service",
            "nullable": true
          },
          "people": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetBreakdownPersonDto"
            },
            "description": "Everyone who logged time in the period, most minutes first",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One period of a job broken down for the Budgets report's drill-down (B28): the period as the progress\nroute gives it, its time by task and by team member. Value of time and the average rate are null\nwithout Fee Budgets ViewAll or while fee budgets are off. A caller restricted to their own time gets\ntheir own minutes on each task (OwnLoggedMinutes), only their own row in People, and no team figures (D8)."
      },
      "BudgetBreakdownPersonDto": {
        "type": "object",
        "properties": {
          "userCode": {
            "type": "string",
            "description": "The team member's user code",
            "nullable": true
          },
          "userName": {
            "type": "string",
            "description": "The team member's name",
            "nullable": true
          },
          "loggedMinutes": {
            "type": "integer",
            "description": "Every minute they logged in the period, billable or not",
            "format": "int32"
          },
          "loggedValue": {
            "type": "number",
            "description": "The value of their time: every entry at its stamped charge-out rate, billable or not (R4)",
            "format": "double",
            "nullable": true
          },
          "averageHourlyRate": {
            "type": "number",
            "description": "The value of their time per hour logged, to the penny: how senior the time on the job was",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A team member's time in a budget period"
      },
      "BudgetBreakdownTaskDto": {
        "type": "object",
        "properties": {
          "taskCode": {
            "type": "string",
            "description": "The task's code; null on the row for time logged straight to the service",
            "nullable": true
          },
          "taskName": {
            "type": "string",
            "description": "The task's name, or \"Time logged straight to the service\"",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "The task's start date; null on the row with no task",
            "format": "date",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "assignedUserName": {
            "type": "string",
            "description": "The name of the team member the task is assigned to, if anyone",
            "nullable": true
          },
          "loggedMinutes": {
            "type": "integer",
            "description": "Every minute logged, billable or not; null for a caller restricted to their own time",
            "format": "int32",
            "nullable": true
          },
          "loggedValue": {
            "type": "number",
            "description": "The value of time: every entry at its stamped charge-out rate, billable or not (R4)",
            "format": "double",
            "nullable": true
          },
          "ownLoggedMinutes": {
            "type": "integer",
            "description": "The caller's own minutes; given only to a caller restricted to their own time",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A task's time in a budget period, or (with no task code) the time logged straight to the service in it"
      },
      "BudgetCycleProgressDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name",
            "nullable": true
          },
          "clientServiceCode": {
            "type": "string",
            "description": "The client service's code",
            "nullable": true
          },
          "serviceName": {
            "type": "string",
            "description": "The catalogue service's name",
            "nullable": true
          },
          "cycleStart": {
            "type": "string",
            "description": "The period's first day",
            "format": "date"
          },
          "cycleEnd": {
            "type": "string",
            "description": "The period's last day; null for a one-off service with no end date",
            "format": "date",
            "nullable": true
          },
          "isCurrent": {
            "type": "boolean",
            "description": "Whether this is the running period of an active service"
          },
          "taskCount": {
            "type": "integer",
            "description": "Tasks in the period that exist (skipped ones left out)",
            "format": "int32"
          },
          "projectedTaskCount": {
            "type": "integer",
            "description": "Tasks in the period not created yet",
            "format": "int32"
          },
          "stepEstimateMinutes": {
            "type": "integer",
            "description": "The period's step estimates, created and projected tasks alike, in minutes",
            "format": "int32"
          },
          "budgetMinutes": {
            "type": "integer",
            "description": "The hours budget in minutes; null when none",
            "format": "int32",
            "nullable": true
          },
          "hoursSource": {
            "$ref": "#/components/schemas/BudgetSource"
          },
          "loggedMinutes": {
            "type": "integer",
            "description": "Every minute logged to the job in the period, billable or not",
            "format": "int32",
            "nullable": true
          },
          "hoursStatus": {
            "$ref": "#/components/schemas/BudgetStatus"
          },
          "feeAmount": {
            "type": "number",
            "description": "The fee budget; null when none",
            "format": "double",
            "nullable": true
          },
          "loggedValue": {
            "type": "number",
            "description": "The value of time: every minute logged, billable or not, at the charge-out rate stamped on its entry (R4)",
            "format": "double",
            "nullable": true
          },
          "feeStatus": {
            "$ref": "#/components/schemas/BudgetStatus"
          },
          "ownLoggedMinutes": {
            "type": "integer",
            "description": "The caller's own minutes; given only to a caller restricted to their own time",
            "format": "int32",
            "nullable": true
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetStageProgressDto"
            },
            "description": "The period's time by service stage, every stage in board order then a line with no stage code for\ntime logged with none; null on totals-only routes and for a service with no stages",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client service's budget and the time logged against it for one billing period. Fee fields\nare null without Fee Budgets ViewAll. For a caller restricted to their own time the team's\nfigures and statuses are null and OwnLoggedMinutes carries their own minutes (D8)."
      },
      "BudgetCycleProgressDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetCycleProgressDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "BudgetLineDto": {
        "type": "object",
        "properties": {
          "stageCode": {
            "type": "string",
            "description": "The stage's code; null for the total",
            "nullable": true
          },
          "stageName": {
            "type": "string",
            "description": "The stage's name; null for the total",
            "nullable": true
          },
          "stageColor": {
            "type": "string",
            "description": "The stage's hex colour, as the board shows it; null for the total or a stage without one",
            "nullable": true
          },
          "stageIcon": {
            "type": "string",
            "description": "The stage's Lucide icon name, as the board shows it; null for the total or a stage without one",
            "nullable": true
          },
          "standardFigure": {
            "type": "number",
            "description": "The standard's figure scaled to the client's billing period, before any percentage",
            "format": "double",
            "nullable": true
          },
          "adjustedFigure": {
            "type": "number",
            "description": "The standard with the client's percentage on top: what the line follows when it has no override",
            "format": "double",
            "nullable": true
          },
          "overrideFigure": {
            "type": "number",
            "description": "The client's own figure for the line, when it has one",
            "format": "double",
            "nullable": true
          },
          "effectiveFigure": {
            "type": "number",
            "description": "The figure the line is measured against",
            "format": "double",
            "nullable": true
          },
          "source": {
            "$ref": "#/components/schemas/BudgetSource"
          }
        },
        "additionalProperties": false,
        "description": "One line of a resolved budget: the total, or one stage when the standard is built by stage.\nHours lines are in minutes, fee lines in money."
      },
      "BudgetLineOverrideRequest": {
        "type": "object",
        "properties": {
          "stageCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The stage's code; null for the total",
            "nullable": true
          },
          "overrideFigure": {
            "maximum": 10000000,
            "minimum": 0.01,
            "type": "number",
            "description": "The client's figure (minutes for hours, money for the fee); null makes the line follow the standard",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The client's own figure for one line: the total (no stage code), or one stage."
      },
      "BudgetReportPeriod": {
        "enum": [
          "Current",
          "Previous",
          "Window"
        ],
        "type": "string",
        "example": "Current"
      },
      "BudgetSource": {
        "enum": [
          "None",
          "Standard",
          "StandardAdjusted",
          "Override",
          "FollowStepEstimates"
        ],
        "type": "string",
        "example": "None"
      },
      "BudgetStageProgressDto": {
        "type": "object",
        "properties": {
          "stageCode": {
            "type": "string",
            "description": "The stage's code; null for time with no stage",
            "nullable": true
          },
          "stageName": {
            "type": "string",
            "description": "The stage's name; null for time with no stage",
            "nullable": true
          },
          "stageColor": {
            "type": "string",
            "description": "The stage's hex colour, as the board shows it; null for time with no stage or a stage without one",
            "nullable": true
          },
          "stageIcon": {
            "type": "string",
            "description": "The stage's Lucide icon name, as the board shows it; null for time with no stage or a stage without one",
            "nullable": true
          },
          "loggedMinutes": {
            "type": "integer",
            "description": "Minutes logged in the stage",
            "format": "int32",
            "nullable": true
          },
          "loggedValue": {
            "type": "number",
            "description": "The value of the stage's time, billable or not, at the stamped rates",
            "format": "double",
            "nullable": true
          },
          "ownLoggedMinutes": {
            "type": "integer",
            "description": "The caller's own minutes in the stage; only for a caller restricted to their own time",
            "format": "int32",
            "nullable": true
          },
          "budgetMinutes": {
            "type": "integer",
            "description": "The stage's hours figure in minutes, when hours are by stage (D10)",
            "format": "int32",
            "nullable": true
          },
          "hoursStatus": {
            "$ref": "#/components/schemas/BudgetStatus"
          },
          "feeAmount": {
            "type": "number",
            "description": "The stage's fee figure, when the fee is by stage",
            "format": "double",
            "nullable": true
          },
          "feeStatus": {
            "$ref": "#/components/schemas/BudgetStatus"
          }
        },
        "additionalProperties": false,
        "description": "The time a budget period logged in one service stage. The stage fields are null on the line for\ntime logged with no stage. Value of time is null without Fee Budgets ViewAll."
      },
      "BudgetStatus": {
        "enum": [
          "NoBudget",
          "Under",
          "Near",
          "Over"
        ],
        "type": "string",
        "example": "NoBudget"
      },
      "BuildingDetails": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "number": {
            "type": "string",
            "nullable": true
          },
          "postcode": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BulkApplyServicePackageRequest": {
        "required": [
          "clientCodes"
        ],
        "type": "object",
        "properties": {
          "clientCodes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The client codes to apply this package to"
          },
          "startDate": {
            "type": "string",
            "description": "The start date for the new service assignments",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "createOnboardingTasks": {
            "type": "boolean",
            "description": "Whether to create onboarding tasks for the assigned services. Defaults to true."
          }
        },
        "additionalProperties": false,
        "description": "Request to apply a service package to multiple clients at once"
      },
      "BulkAssignResult": {
        "type": "object",
        "properties": {
          "assignedCount": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "BulkAssignServiceRequest": {
        "required": [
          "billingFrequency",
          "clientCodes",
          "startDate"
        ],
        "type": "object",
        "properties": {
          "clientCodes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The client codes to assign this service to"
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "price": {
            "type": "number",
            "description": "Optional price override. When omitted, standard pricing is used. Negative values are allowed.",
            "format": "double",
            "nullable": true
          },
          "overridePricing": {
            "type": "boolean",
            "description": "Whether to use a custom price instead of standard pricing.\nWhen true, Price must be provided."
          },
          "startDate": {
            "type": "string",
            "description": "The start date for the new assignments",
            "format": "date-time"
          },
          "status": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "autoInvoice": {
            "type": "boolean",
            "description": "Whether the new assignments should automatically generate invoice line items"
          },
          "createOnboardingTasks": {
            "type": "boolean",
            "description": "Whether to create onboarding tasks for the new assignments.\nSet to false when migrating data from another system."
          },
          "stageCode": {
            "type": "string",
            "description": "Optional stage code to set on the new assignments",
            "nullable": true
          },
          "managedByUserCode": {
            "type": "string",
            "description": "Optional managed-by user code",
            "nullable": true
          },
          "preparerUserCode": {
            "type": "string",
            "description": "Optional Preparer user code. Only meaningful when the service has a Preparer role.",
            "nullable": true
          },
          "reviewerUserCode": {
            "type": "string",
            "description": "Optional Reviewer user code. Only meaningful when the service has a Reviewer role.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to assign a billable service to multiple clients at once"
      },
      "BulkConversationTriageRequest": {
        "required": [
          "items"
        ],
        "type": "object",
        "properties": {
          "setStatus": {
            "type": "boolean",
            "description": "Whether to change the status to SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.StatusCode"
          },
          "statusCode": {
            "maxLength": 100,
            "type": "string",
            "description": "An active email triage status code; required with SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.SetStatus",
            "nullable": true
          },
          "setAssignee": {
            "type": "boolean",
            "description": "Whether to change the assignee to SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.AssigneeCode"
          },
          "assigneeCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The tenant user code to assign the conversation to, who must be able to read the whole mailbox;\nnull unassigns it",
            "nullable": true
          },
          "notifyMeWhenDone": {
            "type": "boolean",
            "description": "With SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.SetAssignee: whether the caller, as the assigner, is told when someone else sets a Done status"
          },
          "silent": {
            "type": "boolean",
            "description": "A background change nobody is told about: no new assignee or assigner hears of it, and an assignee change keeps\nwho assigned the conversation and whether they hear when it is done as they were (so SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.NotifyMeWhenDone\nis ignored). For an assistant that takes a conversation while it works on it and then hands it back."
          },
          "setBringBack": {
            "type": "boolean",
            "description": "Whether to set the bring back to exactly SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.BringBackDate and SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.BringBackStatusCode\n(docs/features/EmailTriage/BRING-BACK-PLAN.md B8), with or without a status change. When false, a change of status\ntakes the new status's default bring back, if it has one, and otherwise clears any pending one."
          },
          "bringBackDate": {
            "type": "string",
            "description": "With SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.SetBringBack: the practice day to bring the conversation back on (at 08:00 UK time), today or\nlater; null removes the bring back",
            "format": "date",
            "nullable": true
          },
          "bringBackStatusCode": {
            "maxLength": 100,
            "type": "string",
            "description": "With SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.SetBringBack and a SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.BringBackDate: the status to bring the conversation back to, an\nactive status that does not mean Done and is not the one the conversation is in",
            "nullable": true
          },
          "items": {
            "maxItems": 100,
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConversationRef"
            },
            "description": "The conversations to change, each by its mailbox and thread id; between 1 and 100"
          }
        },
        "additionalProperties": false,
        "description": "The same triage change on several conversations at once (docs/features/EmailTriage/SHORTCUTS-PLAN.md R8): the\nstatus, the assignee, the bring back, or several of them, as SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest sets them on one.\nThe conversations may be in different mailboxes."
      },
      "BulkConversationTriageResponse": {
        "type": "object",
        "properties": {
          "updated": {
            "type": "integer",
            "description": "How many conversations were changed",
            "format": "int32"
          },
          "skipped": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SkippedConversationDto"
            },
            "description": "The conversations left as they were",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a bulk triage change did: how many conversations were changed, and which were left as they were and why"
      },
      "BulkDeleteClientBillingLineItemsRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The line items to delete. None may be invoiced."
          }
        },
        "additionalProperties": false,
        "description": "Request to delete several of a client's billing line items at once"
      },
      "BulkDeleteClientDocumentsRequest": {
        "required": [
          "documentCodes"
        ],
        "type": "object",
        "properties": {
          "documentCodes": {
            "maxItems": 100,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the documents to delete. Duplicates are ignored."
          }
        },
        "additionalProperties": false,
        "description": "Deletes one or more client documents, including their stored files."
      },
      "BulkDeleteContactsRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "maxItems": 100,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the contacts to delete. Duplicates and unknown codes are ignored."
          }
        },
        "additionalProperties": false,
        "description": "Deletes one or more contacts. Contacts still linked to a client are skipped."
      },
      "BulkDeleteContactsResultDto": {
        "type": "object",
        "properties": {
          "deletedCount": {
            "type": "integer",
            "description": "Number of contacts deleted.",
            "format": "int32"
          },
          "skippedCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of contacts not deleted because they are still linked to a client.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of a bulk contact delete."
      },
      "BulkDeleteDraftEngagementsRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "maxItems": 100,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the proposals to delete. Duplicates and unknown codes are ignored."
          }
        },
        "additionalProperties": false,
        "description": "Deletes one or more draft (unsent) proposals. Proposals that have been sent are skipped."
      },
      "BulkDeleteDraftEngagementsResultDto": {
        "type": "object",
        "properties": {
          "deletedCount": {
            "type": "integer",
            "description": "Number of proposals deleted.",
            "format": "int32"
          },
          "skippedCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of proposals not deleted because they are no longer drafts.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of a bulk draft proposal delete."
      },
      "BulkDeleteResult": {
        "type": "object",
        "properties": {
          "deletedCount": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "BulkDeleteTasksRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      },
      "BulkRemoveClientServicesRequest": {
        "required": [
          "assignments"
        ],
        "type": "object",
        "properties": {
          "assignments": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientServiceReference"
            },
            "description": "The assignments to remove, identified by client code and assignment code"
          }
        },
        "additionalProperties": false,
        "description": "Request to remove multiple client service assignments"
      },
      "BulkRestoreResult": {
        "type": "object",
        "properties": {
          "restoredCount": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "BulkRestoreTasksRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false,
        "description": "The occurrences to restore, as the projected codes\n(proj-{recurringTaskCode}-{clientCode}-{yyyyMMdd}) that deleting them used."
      },
      "BulkSendDataFormRequest": {
        "type": "object",
        "properties": {
          "clientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the clients to send the form to",
            "nullable": true
          },
          "notifyUserCode": {
            "type": "string",
            "description": "The user to notify when clients submit their responses. If not specified, no notification is sent.",
            "nullable": true
          },
          "autoAcceptData": {
            "type": "boolean",
            "description": "When true, submitted data will be automatically accepted and copied to the client record without manual review"
          },
          "message": {
            "type": "string",
            "description": "A message explaining what the client needs to do, included in the notification email",
            "nullable": true
          },
          "recipients": {
            "$ref": "#/components/schemas/EmailRecipientConfig"
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for the chase frequency in days. If not specified, the tenant default is used;\n0 switches chasing off.",
            "format": "int32",
            "nullable": true
          },
          "scheduledAt": {
            "type": "string",
            "description": "When set, the forms are not sent now: no form requests are created until a scheduled send\ndispatches them at this UTC instant. Must be in the future. Omit to send immediately.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for sending a form to multiple clients"
      },
      "BulkTrackExternalFilesRequest": {
        "required": [
          "files"
        ],
        "type": "object",
        "properties": {
          "files": {
            "maxItems": 100,
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TrackExternalFileItemDto"
            },
            "description": "The external files to track. Duplicates are ignored."
          },
          "documentCategoryCode": {
            "type": "string",
            "description": "The document category code to apply to every tracked file. Optional — unknown or omitted codes leave the documents uncategorised.",
            "nullable": true
          },
          "visibleInClientPortal": {
            "type": "boolean",
            "description": "Whether the tracked documents are visible in the client portal. Defaults to false: tracking only publishes a file when asked to."
          },
          "portalFolderPath": {
            "maxLength": 2000,
            "type": "string",
            "description": "Folder path controlling where the documents appear in the client portal, \"/\" separated.\nUsually the storage folder the files are being tracked from, so the portal mirrors the\nstorage layout. Null or empty for the portal root.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Tracks multiple existing external files in Sodium, creating a ClientDocument record for each.\nNo file upload — the files already live in the external storage provider. Titles are derived\nfrom the file names."
      },
      "BulkUpdateClientServicesRequest": {
        "required": [
          "assignments"
        ],
        "type": "object",
        "properties": {
          "assignments": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientServiceReference"
            },
            "description": "The assignments to update, identified by client code and assignment code"
          },
          "price": {
            "type": "number",
            "description": "New price to set. Null = no change. Negative values are allowed.",
            "format": "double",
            "nullable": true
          },
          "overridePricing": {
            "type": "boolean",
            "description": "Whether to override pricing. Null = no change.",
            "nullable": true
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "autoInvoice": {
            "type": "boolean",
            "description": "New auto-invoice setting. Null = no change.",
            "nullable": true
          },
          "stageCode": {
            "type": "string",
            "description": "New stage code. Null = no change. Empty string = clear stage.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ServiceStatus"
          }
        },
        "additionalProperties": false,
        "description": "Request to update fields across multiple client service assignments.\nOnly provided (non-null) fields are updated."
      },
      "BulkUpdateClientsRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of client codes to update"
          },
          "partnerCode": {
            "type": "string",
            "description": "Partner to assign. Null = no change, empty string = unassign, user code = assign.",
            "nullable": true
          },
          "managerCode": {
            "type": "string",
            "description": "Manager to assign. Null = no change, empty string = unassign, user code = assign.",
            "nullable": true
          },
          "associateCode": {
            "type": "string",
            "description": "Associate to assign. Null = no change, empty string = unassign, user code = assign.",
            "nullable": true
          },
          "pclSent": {
            "type": "boolean",
            "description": "PCL sent status. Null = no change.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ClientStatus"
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Teams to assign. Null = no change, empty array = clear all, team codes = replace.",
            "nullable": true
          },
          "contactByPost": {
            "type": "boolean",
            "description": "Whether the clients can be contacted by post. Null = no change.",
            "nullable": true
          },
          "contactByTelephone": {
            "type": "boolean",
            "description": "Whether the clients can be contacted by telephone. Null = no change.",
            "nullable": true
          },
          "contactByEmail": {
            "type": "boolean",
            "description": "Whether the clients can be contacted by email. Null = no change.",
            "nullable": true
          },
          "contactBySms": {
            "type": "boolean",
            "description": "Whether the clients can be contacted by SMS. Null = no change.",
            "nullable": true
          },
          "contactByWhatsApp": {
            "type": "boolean",
            "description": "Whether the clients can be contacted by WhatsApp. Null = no change.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to bulk update multiple clients. At least one update field must be provided.\nFor PartnerCode, ManagerCode, and AssociateCode: null means \"don't change\", a user code means \"assign\", and an empty string means \"unassign\"."
      },
      "BulkUpdateResult": {
        "type": "object",
        "properties": {
          "updatedCount": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "BulkUpdateTasksRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the tasks to update."
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Null = no change, empty string = unassign, value = assign to that user.",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "Null = no change, empty string = clear category, value = set to that category.",
            "nullable": true
          },
          "isAutomationDisabled": {
            "type": "boolean",
            "description": "Null = no change, true = switch automation off, false = switch it on (runs any steps that are ready).",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BulkUpdateWorkflowStepsRequest": {
        "required": [
          "steps"
        ],
        "type": "object",
        "properties": {
          "steps": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepReference"
            },
            "description": "The workflow steps to update, identified by task code + group + step number."
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Null = no change, empty string = unassign, value = assign to that user.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to bulk-update workflow steps across multiple tasks.\nAt least one of Status or AssignedUserCode must be provided."
      },
      "BusinessDetailsDto": {
        "type": "object",
        "properties": {
          "company": {
            "$ref": "#/components/schemas/CompanyDetailsDto"
          },
          "tradingAs": {
            "maxLength": 100,
            "type": "string",
            "description": "Trading name if different from the registered company name",
            "nullable": true
          },
          "postalAddress": {
            "maxLength": 500,
            "type": "string",
            "description": "Postal/correspondence address (may differ from registered address)",
            "nullable": true
          },
          "invoiceAddress": {
            "maxLength": 500,
            "type": "string",
            "description": "Address to use for invoicing purposes",
            "nullable": true
          },
          "dateOfTrading": {
            "type": "string",
            "description": "The date when the business started trading (may differ from incorporation date)",
            "format": "date-time",
            "nullable": true
          },
          "natureOfBusiness": {
            "maxLength": 200,
            "type": "string",
            "description": "Description of what the business does",
            "nullable": true
          },
          "utr": {
            "type": "string",
            "description": "The business Unique Taxpayer Reference (Corporation Tax UTR).\nFor Individual clients, the personal UTR is stored on the Contact record.",
            "nullable": true
          },
          "vat": {
            "$ref": "#/components/schemas/VatDetailsDto"
          },
          "payeRef": {
            "maxLength": 30,
            "type": "string",
            "description": "PAYE reference number for employers (e.g. 123/AB12345). Checked and stored with spaces taken out and upper-cased",
            "nullable": true
          },
          "accountsOfficeRef": {
            "maxLength": 30,
            "type": "string",
            "description": "HMRC Accounts Office reference number (e.g. 123PF00045678). Checked and stored with spaces taken out and upper-cased",
            "nullable": true
          },
          "isCharity": {
            "type": "boolean",
            "description": "The client is a registered, excepted or exempt charity. Settable for Private Limited Company\n(charitable company), Trust (charitable trust) and Association (unincorporated charity);\na Charity (CIO) client is always a charity whatever this says, and the flag is cleared for\nevery other type. Effective status is client type Charity OR this flag.\nUsage in templates: {{ Business.IsCharity }} (resolved to the effective status)"
          },
          "charityNumber": {
            "maxLength": 20,
            "type": "string",
            "description": "Charity registration number: Charity Commission (6-7 digits, optional \"-N\" suffix for a\nlinked charity), OSCR (\"SC0xxxxx\") or CCNI (\"NICxxxxxx\"). Free text; empty for an excepted\nor exempt charity that has no number.\nUsage in templates: {{ Business.CharityNumber }}",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Business-specific details for clients, including companies and sole traders.\nIncludes UK Companies House registration information, addresses, tax details, and SIC codes.\nThis information is typically populated from Companies House API or accounting platform integrations."
      },
      "ButtonStyleDto": {
        "type": "object",
        "properties": {
          "backgroundColor": {
            "type": "string",
            "description": "Button background color in hex format (e.g., \"#1E88E5\")",
            "nullable": true
          },
          "textColor": {
            "type": "string",
            "description": "Button text color in hex format (e.g., \"#FFFFFF\")",
            "nullable": true
          },
          "hoverBackgroundColor": {
            "type": "string",
            "description": "Button hover background color in hex format",
            "nullable": true
          },
          "hoverTextColor": {
            "type": "string",
            "description": "Button hover text color in hex format",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Button styling configuration for a design theme.\nAll properties are nullable - when null, buttons fall back to theme PrimaryColor/SecondaryColor defaults."
      },
      "ByteReadOnlyMemory": {
        "type": "object",
        "properties": {
          "length": {
            "type": "integer",
            "format": "int32",
            "readOnly": true
          },
          "isEmpty": {
            "type": "boolean",
            "readOnly": true
          },
          "span": {
            "$ref": "#/components/schemas/ByteReadOnlySpan"
          }
        },
        "additionalProperties": false
      },
      "ByteReadOnlySpan": {
        "type": "object",
        "properties": {
          "length": {
            "type": "integer",
            "format": "int32",
            "readOnly": true
          },
          "isEmpty": {
            "type": "boolean",
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "CalendarFeedDto": {
        "type": "object",
        "properties": {
          "feedUrl": {
            "type": "string",
            "description": "The secret feed URL to paste into Google Calendar, Outlook or Apple Calendar.\nAnyone holding it can read the feed, so treat it like a password.",
            "nullable": true
          },
          "webcalUrl": {
            "type": "string",
            "description": "The same URL with the webcal scheme, which calendar apps register a handler for.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the feed was first created.",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the URL was last reset. Null if it has never been reset.",
            "format": "date-time",
            "nullable": true
          },
          "lastAccessedAt": {
            "type": "string",
            "description": "When a calendar app last fetched the feed. Null until the first fetch — the signal\nthat a subscription is actually live.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The current user's iCalendar subscription feed."
      },
      "CalendarSubscriptionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying the subscription.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name for the calendar.",
            "nullable": true
          },
          "color": {
            "type": "string",
            "description": "Hex display colour for events from this calendar (e.g. \"#3B82F6\").",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "The ICS feed URL. A secret-address URL grants read access to the source calendar, so\ntreat it like a password.",
            "nullable": true
          },
          "isVisible": {
            "type": "boolean",
            "description": "Whether events from this calendar are currently shown on the task calendar."
          },
          "lastFetchedAt": {
            "type": "string",
            "description": "When the feed was last actually fetched from the source.",
            "format": "date-time",
            "nullable": true
          },
          "lastFetchStatus": {
            "$ref": "#/components/schemas/CalendarSubscriptionFetchStatus"
          },
          "lastFetchError": {
            "type": "string",
            "description": "Why the most recent fetch failed. Null while the feed is healthy.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the subscription was created.",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the subscription was last edited. Null if never edited.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One of the current user's external calendar subscriptions."
      },
      "CalendarSubscriptionFetchStatus": {
        "enum": [
          "NeverFetched",
          "Ok",
          "Failed"
        ],
        "type": "string",
        "example": "NeverFetched"
      },
      "CancelClientApprovalRequest": {
        "type": "object",
        "properties": {
          "removeFromClientPortal": {
            "type": "boolean",
            "description": "Whether the cancelled documents are also hidden from the client portal."
          }
        },
        "additionalProperties": false,
        "description": "Options for cancelling a pending approval request. Requesting approval shares the document in\nthe client portal, and cancelling leaves it shared: a document sent by mistake stays visible\nto the client unless it is removed here."
      },
      "CapacityCellDto": {
        "type": "object",
        "properties": {
          "availableMinutes": {
            "type": "integer",
            "description": "Minutes the person is available: their working pattern's hours with bank and practice\nholidays and their own time off taken out, from today in the current period. Null on team and unassigned rows,\nwhich have nobody's hours behind them",
            "format": "int32",
            "nullable": true
          },
          "plannedMinutes": {
            "type": "integer",
            "description": "Remaining estimated minutes of the open work planned in the period",
            "format": "int32"
          },
          "unestimatedCount": {
            "type": "integer",
            "description": "Pieces of open work in the period that have no estimate, so add nothing to the planned\nminutes. Shown so a blank estimate doesn't pass for spare capacity",
            "format": "int32"
          },
          "timeOffMinutes": {
            "type": "integer",
            "description": "Minutes the person's time off took out of their available hours in the period",
            "format": "int32"
          },
          "onTimeOffCount": {
            "type": "integer",
            "description": "Pieces of work in the period planned onto days the person is off, which need moving or\nreassigning",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One row's figures for one period."
      },
      "CapacityItemDto": {
        "type": "object",
        "properties": {
          "taskCode": {
            "type": "string",
            "nullable": true
          },
          "taskName": {
            "type": "string",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "nullable": true
          },
          "groupNumber": {
            "type": "integer",
            "description": "The step's group number, for reassigning the step. Null when the item is a whole task",
            "format": "int32",
            "nullable": true
          },
          "stepNumber": {
            "type": "integer",
            "description": "The step's number within its group, for reassigning the step. Null when the item is a whole task",
            "format": "int32",
            "nullable": true
          },
          "stepName": {
            "type": "string",
            "description": "Null when the item is a whole task",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "The first day in the period the work is planned on",
            "format": "date"
          },
          "dueDate": {
            "type": "string",
            "description": "The task's due date",
            "format": "date"
          },
          "estimateMinutes": {
            "type": "integer",
            "description": "The whole estimate. Null when the work has none",
            "format": "int32",
            "nullable": true
          },
          "loggedMinutes": {
            "type": "integer",
            "description": "Time logged against it so far",
            "format": "int32"
          },
          "remainingMinutes": {
            "type": "integer",
            "description": "The estimate still to do: the estimate less the time logged, never below zero",
            "format": "int32"
          },
          "plannedMinutes": {
            "type": "integer",
            "description": "The part of the remaining estimate planned inside this period. Less than the remaining\nestimate when a task is spread over working days that run past the period",
            "format": "int32"
          },
          "isLate": {
            "type": "boolean",
            "description": "True when the work was planned for before today, so has been moved onto today"
          },
          "isOnTimeOff": {
            "type": "boolean",
            "description": "True when the work is planned onto a day the assignee is off"
          },
          "isProjected": {
            "type": "boolean",
            "description": "True for future recurring work not yet created as a task. The task code is then the\nprojected task's code, which must be materialised before the work can be changed"
          }
        },
        "additionalProperties": false,
        "description": "One piece of work behind a Capacity report cell: a workflow step, or a whole task when its\nestimate isn't split into steps."
      },
      "CapacityPeriodDto": {
        "type": "object",
        "properties": {
          "startDate": {
            "type": "string",
            "description": "First day of the period (inclusive)",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "Last day of the period (inclusive)",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "One column of the Capacity report."
      },
      "CapacityReportDto": {
        "type": "object",
        "properties": {
          "periods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CapacityPeriodDto"
            },
            "description": "The report's columns, in date order. Every row's cells line up with these",
            "nullable": true
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CapacityRowDto"
            },
            "description": "The people first (current members by name, then anyone else still holding open work),\nthen work held by a team, then unassigned work",
            "nullable": true
          },
          "total": {
            "$ref": "#/components/schemas/CapacityRowDto"
          },
          "today": {
            "type": "string",
            "description": "The date the report counts from. Available hours in the current period start here, and\nopen work dated earlier (already late) is planned onto it",
            "format": "date"
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Capacity report: for each person, week by week or month by month, the hours of open\nwork planned against them next to the hours they're available, so a manager can see who is\nover or under loaded and move work. Starts at the current period and looks forward."
      },
      "CapacityRowDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The TenantUser or Team code. Null for the unassigned row and the total",
            "nullable": true
          },
          "kind": {
            "$ref": "#/components/schemas/ReportGroupKind"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "isFormerMember": {
            "type": "boolean",
            "description": "True for a person who is no longer a current member but still holds open work"
          },
          "cells": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CapacityCellDto"
            },
            "description": "One cell per period, in the same order as the report's periods",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One row of the Capacity report: a person, the work held by a team, or the unassigned work."
      },
      "CapitalLosses": {
        "type": "object",
        "properties": {
          "broughtForwardLossesUsedInCurrentYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "setAgainstInYearGains": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "setAgainstEarlierYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "lossesToCarryForward": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CarryBackLossesDecrease": {
        "type": "object",
        "properties": {
          "incomeTax": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "class4": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "capitalGainsTax": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CatchUpFeeDto": {
        "type": "object",
        "properties": {
          "months": {
            "type": "number",
            "description": "Months of backlog the fee covers, counted back from the service start date (over 0, up to\n120, fractions allowed)",
            "format": "double"
          },
          "fee": {
            "type": "number",
            "description": "The agreed fee for the backlog. Suggested value: the monthly-equivalent rate times the months.\nNegative values are allowed.",
            "format": "double"
          },
          "instalments": {
            "type": "integer",
            "description": "How many invoices the fee is spread over, 1 (a single payment) to 12. Instalment 1 bills at\nthe billing moment; each later instalment rides on the service's next recurring invoice. More\nthan 1 needs a recurring billing frequency.",
            "format": "int32"
          },
          "billingMoment": {
            "$ref": "#/components/schemas/SetupFeeBillingMoment"
          }
        },
        "additionalProperties": false,
        "description": "A client service's catch-up fee (story 2109): a one-off charge for the backlog before the\nservice start date. Present on a service means there is one; absent means there is not."
      },
      "CgtPpdOverrides": {
        "type": "object",
        "properties": {
          "ppdYearToDate": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "multiplePropertyDisposals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PpdMultiplePropertyDisposal"
            },
            "nullable": true
          },
          "singlePropertyDisposals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PpdSinglePropertyDisposal"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CgtResidentialDisposals": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "disposals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResidentialDisposal"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ChangeSubscriptionRequest": {
        "required": [
          "packageCode"
        ],
        "type": "object",
        "properties": {
          "packageCode": {
            "minLength": 1,
            "type": "string",
            "description": "The package to subscribe to."
          }
        },
        "additionalProperties": false,
        "description": "Request to change a tenant's subscription to a different package.\nThe pricing tier is automatically determined based on the tenant's active client count."
      },
      "ChangeTenantUserRateRequest": {
        "type": "object",
        "properties": {
          "hourlyRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Charge-out rate per hour. Null gives the user no rate of their own for the period,\nso the practice default applies.",
            "format": "double",
            "nullable": true
          },
          "costRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Internal cost rate per hour. Setting a value requires the Cost Rates permission;\ncallers without it leave the stored cost rate unchanged.",
            "format": "double",
            "nullable": true
          },
          "preserveHistory": {
            "type": "boolean",
            "description": "True keeps the previous rate on record for historical periods: the current entry is\nclosed the day before EffectiveFrom and a new current entry begins. False corrects\nthe current entry in place, as if the new rates had always applied."
          },
          "effectiveFrom": {
            "type": "string",
            "description": "The first day the new rates apply. Required when preserving history (and when the\nuser has closed entries but no current one); ignored when correcting in place.",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Changes a team member's current rates. When the user has no rate entries yet, one is\ncreated. Otherwise PreserveHistory decides whether the previous rate is kept on record\n(the open entry is closed and a new one starts at EffectiveFrom) or simply corrected\nin place. Either way, rates already stamped on logged time are never changed."
      },
      "ChangeWorkTypeRateRequest": {
        "type": "object",
        "properties": {
          "taskCategoryCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The task category to price. Give this or billableServiceCode, not both.",
            "nullable": true
          },
          "billableServiceCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The library service to price. Give this or taskCategoryCode, not both.",
            "nullable": true
          },
          "hourlyRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Charge-out rate per hour. Null leaves the charge-out rate to the next rule down.",
            "format": "double",
            "nullable": true
          },
          "costRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Internal cost rate per hour. Setting a value requires the Cost Rates permission; callers\nwithout it leave the stored cost rate unchanged.",
            "format": "double",
            "nullable": true
          },
          "preserveHistory": {
            "type": "boolean",
            "description": "True keeps the previous rate on record for historical periods: the current entry is\nclosed the day before EffectiveFrom and a new current entry begins. False corrects the\ncurrent entry in place, as if the new rates had always applied."
          },
          "effectiveFrom": {
            "type": "string",
            "description": "The first day the new rates apply. Required when preserving history (and when the type of\nwork has closed entries but no current one). Otherwise null means \"since forever\".",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Sets the current rate for a type of work. When the type of work has no rate entries yet\n(for this team member, or for the practice), one is created. Otherwise PreserveHistory\ndecides whether the previous rate is kept on record (the open entry is closed and a new one\nstarts at EffectiveFrom) or simply corrected in place. Either way, rates already stamped on\nlogged time are not changed."
      },
      "CharitableGifts": {
        "type": "object",
        "properties": {
          "nonUkCharities": {
            "$ref": "#/components/schemas/NonUkCharities"
          },
          "landAndBuildings": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "sharesOrSecurities": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CharitableGivingReliefs": {
        "type": "object",
        "properties": {
          "giftAidPayments": {
            "$ref": "#/components/schemas/GiftAidPayments"
          },
          "gifts": {
            "$ref": "#/components/schemas/CharitableGifts"
          }
        },
        "additionalProperties": false
      },
      "Charity": {
        "type": "object",
        "properties": {
          "charityNumber": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "charityType": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/CharityRegistrationStatus"
          },
          "dateOfRemoval": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "removalReason": {
            "type": "string",
            "nullable": true
          },
          "address": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "website": {
            "type": "string",
            "nullable": true
          },
          "companyNumber": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CharityRegistrationStatus": {
        "enum": [
          "Registered",
          "Removed"
        ],
        "type": "string",
        "example": "Registered"
      },
      "CharitySearchResult": {
        "type": "object",
        "properties": {
          "charityNumber": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CharityTrustee": {
        "type": "object",
        "properties": {
          "trusteeId": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "isChair": {
            "type": "boolean"
          },
          "dateOfAppointment": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "otherCharities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CharityTrusteeOtherCharity"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CharityTrusteeOtherCharity": {
        "type": "object",
        "properties": {
          "charityNumber": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ChaseScheduleDto": {
        "type": "object",
        "properties": {
          "frequencyDays": {
            "type": "integer",
            "description": "How often (in days) the client is chased. Null means chasing is disabled.",
            "format": "int32",
            "nullable": true
          },
          "lastChasedDate": {
            "type": "string",
            "description": "When the client was last chased. Null if never chased.",
            "format": "date-time",
            "nullable": true
          },
          "nextChaseDate": {
            "type": "string",
            "description": "When the next chase is due. Null when chasing is off or nothing is outstanding.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The automatic-chase schedule for something the practice is waiting on a client for —\na document approval, a document request, a data form, a workflow step.\n            \nShared by every DTO that can be chased so the three fields keep one shape and one meaning.\nAlways present; a null SodiumHQ.DTOs.Base.ChaseScheduleDto.FrequencyDays means chasing is off for this item, in\nwhich case there is no next chase either."
      },
      "CheckHmrcBulkRequestDto": {
        "required": [
          "authorisationType"
        ],
        "type": "object",
        "properties": {
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          },
          "clientCodes": {
            "maxItems": 1000,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The clients to check. Null checks every client whose services need this authorisation and who has not had it\nrequested yet.",
            "nullable": true
          },
          "inviteClient": {
            "type": "boolean",
            "description": "Whether the clients will be emailed the code entry link, which needs an email address for each."
          }
        },
        "additionalProperties": false,
        "description": "Asks which of a set of clients are ready for one 64-8 authorisation to be requested from HMRC, and what the rest are\nmissing"
      },
      "ChecklistDto": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this recurring task template.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Wraps the checklist items applied to tasks created from a recurring task template."
      },
      "ChecklistItemDto": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "nullable": true
          },
          "isCompleted": {
            "type": "boolean"
          },
          "sortOrder": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "CisAddedSubcontractorDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The subcontractor's code in CIS Manager",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The subcontractor's name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A subcontractor the client added to CIS Manager from a Collect CIS payments page."
      },
      "CisCollectPaymentsExecutionStateDto": {
        "type": "object",
        "properties": {
          "taxMonthEnd": {
            "type": "string",
            "description": "The 5th the tax month ends on",
            "format": "date"
          },
          "organisationCode": {
            "type": "string",
            "description": "The client's CIS Manager organisation (its tenant code)",
            "nullable": true
          },
          "tokenSentAt": {
            "type": "string",
            "description": "UTC time the link was emailed (client mode)",
            "format": "date-time",
            "nullable": true
          },
          "submittedAt": {
            "type": "string",
            "description": "UTC time the payments were submitted, or the step completed by staff",
            "format": "date-time",
            "nullable": true
          },
          "submittedByEmail": {
            "type": "string",
            "description": "Email address of the recipient who submitted (from their magic link), or of the staff user",
            "nullable": true
          },
          "noPaymentsDeclared": {
            "type": "boolean",
            "description": "Whether the submission declared that no payments were made in the tax month"
          },
          "paymentCount": {
            "type": "integer",
            "description": "The number of payments in CIS Manager for the month when submitted",
            "format": "int32"
          },
          "totalGross": {
            "type": "number",
            "description": "The month's gross payments when submitted",
            "format": "double"
          },
          "totalDeductions": {
            "type": "number",
            "description": "The month's deductions when submitted",
            "format": "double"
          },
          "addedSubcontractors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CisAddedSubcontractorDto"
            },
            "description": "The subcontractors the client added to CIS Manager from the payments page: unverified, so deducted at 30% until a\nVerify subcontractors step (or the practice) verifies them",
            "nullable": true
          },
          "lastSavedAt": {
            "type": "string",
            "description": "UTC time the client last saved the payments page",
            "format": "date-time",
            "nullable": true
          },
          "paidCount": {
            "type": "integer",
            "description": "The month's paid payments, as last counted",
            "format": "int32"
          },
          "readyToPayCount": {
            "type": "integer",
            "description": "The month's payments not paid yet whose subcontractor is verified, as last counted",
            "format": "int32"
          },
          "awaitingVerificationCount": {
            "type": "integer",
            "description": "The month's payments not paid yet whose subcontractor is not verified yet, as last counted",
            "format": "int32"
          },
          "announcedPayableContacts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the subcontractors the client has already been told they can now pay, so that email is not repeated",
            "nullable": true
          },
          "awaitingVerificationContacts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the subcontractors the page has had payments awaiting verification for; announced as payable once\nthey have payments ready to pay",
            "nullable": true
          },
          "lastPolledAt": {
            "type": "string",
            "description": "UTC time the counts were last read from CIS Manager while the client keeps the page up to date",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Execution state of an Open CIS payments page step (`CisCollectPayments`). Read-only: written by the system.\nStaff mode records only the month and organisation until the step is completed."
      },
      "CisCollectPaymentsStepConfigDto": {
        "type": "object",
        "properties": {
          "collectedBy": {
            "$ref": "#/components/schemas/CisPaymentsCollectedBy"
          },
          "taxMonth": {
            "$ref": "#/components/schemas/TaxMonthChoice"
          },
          "subjectLine": {
            "maxLength": 500,
            "type": "string",
            "description": "Client mode: optional email subject line override (Liquid). When empty, the portal settings content block's\nsubject is used.",
            "nullable": true
          },
          "messageHtml": {
            "type": "string",
            "description": "Client mode: the message at the top of the portal page (Liquid)",
            "nullable": true
          },
          "allowNoPayments": {
            "type": "boolean",
            "description": "Whether the client may declare that no payments were made in the tax month"
          },
          "allowNewSubcontractors": {
            "type": "boolean",
            "description": "Whether the client may add a subcontractor to CIS Manager from the page (unverified until verified with HMRC)"
          },
          "notifyAssigneeOnSubmission": {
            "type": "boolean",
            "description": "Whether to notify the step's assignee when the client submits"
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to send the email to the client's business email (the email address on the client record)."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types to send the email to.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to send the email to.",
            "nullable": true
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for how often (in days) to chase the client. When null, the tenant-level default is used.",
            "format": "int32",
            "nullable": true
          },
          "alsoSendText": {
            "type": "boolean",
            "description": "Also text each email recipient who is one of the client's contacts with a mobile, by SMS, with the same link as\ntheir email, worded by the practice's text wording for this kind of request. Ignored while the practice's\nmessaging is not Active."
          }
        },
        "additionalProperties": false,
        "description": "Configuration for Collect CIS payments workflow steps: who enters the tax month's subcontractor payments, and for\nclient mode the email and portal page."
      },
      "CisConfirmReturnExecutionStateDto": {
        "type": "object",
        "properties": {
          "taxMonthEnd": {
            "type": "string",
            "description": "The 5th the tax month ends on",
            "format": "date"
          },
          "organisationCode": {
            "type": "string",
            "description": "The client's CIS Manager organisation (its tenant code)",
            "nullable": true
          },
          "tokenSentAt": {
            "type": "string",
            "description": "UTC time the link was emailed",
            "format": "date-time",
            "nullable": true
          },
          "confirmedAt": {
            "type": "string",
            "description": "UTC time the contractor confirmed",
            "format": "date-time",
            "nullable": true
          },
          "confirmedByEmail": {
            "type": "string",
            "description": "Email address of the recipient who confirmed (from their magic link)",
            "nullable": true
          },
          "queriedAt": {
            "type": "string",
            "description": "UTC time the contractor queried the return",
            "format": "date-time",
            "nullable": true
          },
          "queryMessage": {
            "type": "string",
            "description": "What the contractor said isn't right",
            "nullable": true
          },
          "isNilReturn": {
            "type": "boolean",
            "description": "Whether the return has no payments"
          },
          "subcontractorCount": {
            "type": "integer",
            "description": "The number of subcontractors on the return as confirmed",
            "format": "int32"
          },
          "totalGross": {
            "type": "number",
            "description": "Gross payments on the return as confirmed",
            "format": "double"
          },
          "totalMaterials": {
            "type": "number",
            "description": "Materials on the return as confirmed",
            "format": "double"
          },
          "totalDeductions": {
            "type": "number",
            "description": "Deductions on the return as confirmed",
            "format": "double"
          },
          "returnSnapshotJson": {
            "type": "string",
            "description": "The return's breakdown as the contractor saw it when they confirmed, as JSON",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Execution state of a Confirm CIS return step. Read-only: written by the system."
      },
      "CisConfirmReturnStepConfigDto": {
        "required": [
          "buttonText"
        ],
        "type": "object",
        "properties": {
          "taxMonth": {
            "$ref": "#/components/schemas/TaxMonthChoice"
          },
          "subjectLine": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional email subject line override (Liquid). When empty, the portal settings content block's subject is used.",
            "nullable": true
          },
          "messageHtml": {
            "type": "string",
            "description": "The message on the portal page above the return (Liquid)",
            "nullable": true
          },
          "buttonText": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "Text of the confirm button on the portal page"
          },
          "thankYouMessageHtml": {
            "type": "string",
            "description": "The message shown after the contractor confirms (Liquid)",
            "nullable": true
          },
          "allowQuery": {
            "type": "boolean",
            "description": "Whether the contractor may say something isn't right instead of confirming; a query blocks the step"
          },
          "notifyAssigneeOnConfirmation": {
            "type": "boolean",
            "description": "Whether to notify the step's assignee when the contractor confirms"
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to send the email to the client's business email (the email address on the client record)."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types to send the email to.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to send the email to.",
            "nullable": true
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for how often (in days) to chase the client. When null, the tenant-level default is used.",
            "format": "int32",
            "nullable": true
          },
          "alsoSendText": {
            "type": "boolean",
            "description": "Also text each email recipient who is one of the client's contacts with a mobile, by SMS, with the same link as\ntheir email, worded by the practice's text wording for this kind of request. Ignored while the practice's\nmessaging is not Active."
          }
        },
        "additionalProperties": false,
        "description": "Configuration for Confirm CIS return workflow steps: the contractor confirms or queries the tax month's return\nthrough the portal before it is filed."
      },
      "CisFileNilReturnStepConfigDto": {
        "type": "object",
        "properties": {
          "taxMonth": {
            "$ref": "#/components/schemas/TaxMonthChoice"
          },
          "declareInactivity": {
            "type": "boolean",
            "description": "Also tells HMRC no payments to subcontractors are expected in the next six months, so HMRC stops expecting\nreturns until the contractor pays one again"
          },
          "notifyAssigneeOnOutcome": {
            "type": "boolean",
            "description": "Whether to notify the step's assignee when HMRC accepts or rejects the return"
          }
        },
        "additionalProperties": false,
        "description": "Configuration for File nil CIS return workflow steps. A nil return carries no declarations, so the step can always\nrun on its own; it blocks when CIS Manager has payments for the month."
      },
      "CisInvoiceNotReratedDto": {
        "type": "object",
        "properties": {
          "number": {
            "type": "integer",
            "description": "The invoice's number in CIS Manager",
            "format": "int32"
          },
          "contactCode": {
            "type": "string",
            "description": "The subcontractor's code",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "description": "Why it was left alone, as people read it",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A purchase invoice CIS Manager did not re-rate to its subcontractor's verified rate."
      },
      "CisManagerReturnDto": {
        "type": "object",
        "properties": {
          "year": {
            "type": "integer",
            "description": "The calendar year the tax month ends in",
            "format": "int32"
          },
          "month": {
            "type": "integer",
            "description": "The calendar month the tax month ends in (on the 5th)",
            "format": "int32"
          },
          "status": {
            "$ref": "#/components/schemas/CisReturnStatus"
          },
          "dueDate": {
            "type": "string",
            "description": "When it is due at HMRC (the 19th)",
            "format": "date"
          },
          "isOverdue": {
            "type": "boolean",
            "description": "Not accepted and past its due date"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "HMRC's or the submission's errors, when in error",
            "nullable": true
          },
          "submissionBlockedReason": {
            "type": "string",
            "description": "Why it cannot be submitted now (filing credits, billing), or null",
            "nullable": true
          },
          "creditsRequired": {
            "type": "integer",
            "description": "The filing credits submitting it will use, when it is paid for with them",
            "format": "int32",
            "nullable": true
          },
          "invoiceCount": {
            "type": "integer",
            "description": "The invoices paid in the month",
            "format": "int32"
          },
          "contactCount": {
            "type": "integer",
            "description": "The subcontractors paid in the month",
            "format": "int32"
          },
          "deductions": {
            "type": "number",
            "description": "The CIS deducted in the month",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "One CIS monthly return, identified by the calendar year and month its tax month ends in"
      },
      "CisManagerReturnsDto": {
        "type": "object",
        "properties": {
          "isContractor": {
            "type": "boolean",
            "description": "Whether the client is a contractor in CIS Manager; only a contractor files returns"
          },
          "currentYear": {
            "type": "integer",
            "description": "The calendar year the tax month in progress ends in",
            "format": "int32"
          },
          "currentMonth": {
            "type": "integer",
            "description": "The calendar month the tax month in progress ends in (on the 5th)",
            "format": "int32"
          },
          "currentDueDate": {
            "type": "string",
            "description": "When the current month's return is due at HMRC (the 19th)",
            "format": "date"
          },
          "current": {
            "$ref": "#/components/schemas/CisManagerReturnDto"
          },
          "needsAttention": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CisManagerReturnDto"
            },
            "description": "Earlier returns still open after their month ended, or in error; latest first",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client's CIS returns as CIS Manager has them: the return for the tax month in progress and the earlier ones\nneeding attention"
      },
      "CisManagerSettingsDto": {
        "type": "object",
        "properties": {
          "cisPaymentsEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "cisReturnConfirmationEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "cisPaymentsReminderEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "cisPaymentsPayableEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "The practice's CIS Manager settings (Settings > Sodium Apps > CIS Manager): the email templates the CIS Manager\nclient steps send with"
      },
      "CisOrganisationMatch": {
        "enum": [
          "None",
          "Name",
          "Utr",
          "Paye",
          "PayeAndAccountsOffice"
        ],
        "type": "string",
        "example": "None"
      },
      "CisPaidAtDifferentRateDto": {
        "type": "object",
        "properties": {
          "number": {
            "type": "integer",
            "description": "The invoice's number in CIS Manager",
            "format": "int32"
          },
          "contactCode": {
            "type": "string",
            "description": "The subcontractor's code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The subcontractor's name",
            "nullable": true
          },
          "taxStatus": {
            "$ref": "#/components/schemas/CisTaxStatus"
          },
          "verifiedTaxStatus": {
            "$ref": "#/components/schemas/CisTaxStatus"
          }
        },
        "additionalProperties": false,
        "description": "A payment of the tax month made at another rate than the one HMRC gave its subcontractor."
      },
      "CisPaymentsCollectedBy": {
        "enum": [
          "Staff",
          "Client"
        ],
        "type": "string",
        "example": "Staff"
      },
      "CisRemindPaymentsExecutionStateDto": {
        "type": "object",
        "properties": {
          "taxMonthEnd": {
            "type": "string",
            "description": "The 5th the tax month ends on",
            "format": "date"
          },
          "organisationCode": {
            "type": "string",
            "description": "The client's CIS Manager organisation (its tenant code)",
            "nullable": true
          },
          "sentAt": {
            "type": "string",
            "description": "UTC time the reminder was emailed; null when it sent nothing",
            "format": "date-time",
            "nullable": true
          },
          "skippedBecauseFinished": {
            "type": "boolean",
            "description": "Whether the step completed without sending because the client had already finished the month"
          },
          "paidCount": {
            "type": "integer",
            "description": "The month's paid payments when the reminder was sent",
            "format": "int32"
          },
          "readyToPayCount": {
            "type": "integer",
            "description": "The month's payments not paid yet whose subcontractor is verified, when the reminder was sent",
            "format": "int32"
          },
          "awaitingVerificationCount": {
            "type": "integer",
            "description": "The month's payments not paid yet whose subcontractor is not verified yet, when the reminder was sent",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Execution state of a Remind client about CIS payments step. Read-only: written by the system."
      },
      "CisRemindPaymentsStepConfigDto": {
        "type": "object",
        "properties": {
          "taxMonth": {
            "$ref": "#/components/schemas/TaxMonthChoice"
          },
          "subjectLine": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional email subject line override (Liquid). When empty, the portal settings content block's subject is used.",
            "nullable": true
          },
          "messageHtml": {
            "type": "string",
            "description": "The reminder's message (Liquid)",
            "nullable": true
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to send the email to the client's business email (the email address on the client record)."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types to send the email to.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to send the email to.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for Remind client about CIS payments workflow steps: sends the client the link of the task's Open CIS\npayments page step again. Its timing is the step's planned date."
      },
      "CisReturnStatus": {
        "enum": [
          "Open",
          "Submitted",
          "Accepted",
          "Error",
          "Submitting"
        ],
        "type": "string",
        "example": "Open"
      },
      "CisStepPaymentsSummaryDto": {
        "type": "object",
        "properties": {
          "paidCount": {
            "type": "integer",
            "description": "The invoices paid in the month",
            "format": "int32"
          },
          "readyToPayCount": {
            "type": "integer",
            "description": "The invoices not paid yet whose subcontractor is verified",
            "format": "int32"
          },
          "awaitingVerificationCount": {
            "type": "integer",
            "description": "The invoices not paid yet whose subcontractor is not verified yet",
            "format": "int32"
          },
          "awaitingVerificationSubcontractors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CisStepSubcontractorDto"
            },
            "description": "The subcontractors with payments awaiting verification with HMRC",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A tax month's payments as the Open CIS payments page shows them, read live: paid in the month, and those not paid\nyet either ready to pay (subcontractor verified) or awaiting verification."
      },
      "CisStepReturnSummaryDto": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/CisReturnStatus"
          },
          "invoiceCount": {
            "type": "integer",
            "description": "How many invoices fall in the month: none is a nil return",
            "format": "int32"
          },
          "contactCount": {
            "type": "integer",
            "description": "How many subcontractors were paid in the month",
            "format": "int32"
          },
          "labour": {
            "type": "number",
            "description": "Labour paid in the month",
            "format": "double"
          },
          "materials": {
            "type": "number",
            "description": "Materials paid in the month",
            "format": "double"
          },
          "deductions": {
            "type": "number",
            "description": "CIS deducted in the month",
            "format": "double"
          },
          "statusMessage": {
            "type": "string",
            "description": "HMRC's IRmark message once the return is accepted",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A tax month's CIS return as CIS Manager has it."
      },
      "CisStepSubcontractorDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The subcontractor's code in CIS Manager",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The subcontractor's name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A subcontractor in CIS Manager."
      },
      "CisStepSummaryDto": {
        "type": "object",
        "properties": {
          "taxMonth": {
            "type": "string",
            "description": "The tax month in words, e.g. \"6 April to 5 May 2026\"",
            "nullable": true
          },
          "return": {
            "$ref": "#/components/schemas/CisStepReturnSummaryDto"
          },
          "paymentCount": {
            "type": "integer",
            "description": "How many purchase invoices were paid in the month",
            "format": "int32"
          },
          "lastPaymentDate": {
            "type": "string",
            "description": "The latest date a purchase invoice was paid in the month; null when none was",
            "format": "date",
            "nullable": true
          },
          "payments": {
            "$ref": "#/components/schemas/CisStepPaymentsSummaryDto"
          }
        },
        "additionalProperties": false,
        "description": "Where a CIS Manager step's tax month stands in CIS Manager, read live for its task card: the month, the return\n(when CIS Manager has one) and the payments recorded in the month."
      },
      "CisSubcontractorIssueDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The subcontractor's code in CIS Manager",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The subcontractor's name",
            "nullable": true
          },
          "message": {
            "type": "string",
            "description": "HMRC's message, or what CIS Manager says is missing",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A subcontractor a Verify subcontractors step could not verify, and why."
      },
      "CisSubmitReturnExecutionStateDto": {
        "type": "object",
        "properties": {
          "taxMonthEnd": {
            "type": "string",
            "description": "The 5th the tax month ends on",
            "format": "date"
          },
          "organisationCode": {
            "type": "string",
            "description": "The client's CIS Manager organisation (its tenant code)",
            "nullable": true
          },
          "submittedAt": {
            "type": "string",
            "description": "UTC time the return was submitted (or found already submitted)",
            "format": "date-time",
            "nullable": true
          },
          "submittedBy": {
            "type": "string",
            "description": "Who submitted: the user's email address, or \"System\" for an automatic run",
            "nullable": true
          },
          "isNilReturn": {
            "type": "boolean",
            "description": "Whether the return had no payments (no declarations sent)"
          },
          "employmentStatusDeclared": {
            "type": "boolean",
            "description": "Whether the employment status declaration was sent"
          },
          "verificationDeclared": {
            "type": "boolean",
            "description": "Whether the verification declaration was sent"
          },
          "inactivityDeclared": {
            "type": "boolean",
            "description": "Whether the nil return also told HMRC no payments are expected in the next six months"
          },
          "totalDeductions": {
            "type": "number",
            "description": "Deductions on the return when submitted",
            "format": "double"
          },
          "acceptedAt": {
            "type": "string",
            "description": "UTC time HMRC's acceptance was seen",
            "format": "date-time",
            "nullable": true
          },
          "correlationId": {
            "type": "string",
            "description": "HMRC's correlation id for the submission",
            "nullable": true
          },
          "irMarkMessage": {
            "type": "string",
            "description": "HMRC's IRmark message once the return is accepted",
            "nullable": true
          },
          "errorMessage": {
            "type": "string",
            "description": "HMRC's error, as CIS Manager translated it, when the return was rejected",
            "nullable": true
          },
          "lastPolledAt": {
            "type": "string",
            "description": "UTC time the poll last read the return's status",
            "format": "date-time",
            "nullable": true
          },
          "filedOutsideStep": {
            "type": "boolean",
            "description": "Whether the return was already submitted or accepted in CIS Manager when the step ran"
          }
        },
        "additionalProperties": false,
        "description": "Execution state of a Submit CIS return step. Read-only: written by the system. The poll\nfills in the outcome."
      },
      "CisSubmitReturnRequest": {
        "type": "object",
        "properties": {
          "declareEmploymentStatus": {
            "type": "boolean",
            "description": "HMRC's declaration that the employment status of every subcontractor was considered"
          },
          "declareVerification": {
            "type": "boolean",
            "description": "HMRC's declaration that every subcontractor was verified with HMRC where required"
          },
          "ignoreConfirmedChanges": {
            "type": "boolean",
            "description": "Submit even when the return's totals differ from those the contractor confirmed on a Confirm CIS return step\nfor the same tax month (otherwise refused with that reason)"
          }
        },
        "additionalProperties": false,
        "description": "\"Submit to HMRC\" on a Submit CIS return step's task card: submits the tax month's return through CIS Manager as the\nsigned-in user, with the declarations ticked at the time. A nil return sends neither declaration."
      },
      "CisSubmitReturnStepConfigDto": {
        "type": "object",
        "properties": {
          "taxMonth": {
            "$ref": "#/components/schemas/TaxMonthChoice"
          },
          "declareEmploymentStatus": {
            "type": "boolean",
            "description": "Declares that the employment status of every subcontractor was considered"
          },
          "declareVerification": {
            "type": "boolean",
            "description": "Declares that every subcontractor was verified with HMRC where required"
          },
          "notifyAssigneeOnOutcome": {
            "type": "boolean",
            "description": "Whether to notify the step's assignee when HMRC accepts or rejects the return"
          }
        },
        "additionalProperties": false,
        "description": "Configuration for Submit CIS return workflow steps. With both declarations ticked the step may submit on its own;\notherwise the task card asks for them when someone submits. A nil return sends neither."
      },
      "CisTaxStatus": {
        "enum": [
          "NetOfHigherDeduction",
          "NetOfStandardDeduction",
          "Gross"
        ],
        "type": "string",
        "example": "NetOfHigherDeduction"
      },
      "CisUnmatchedSubcontractorAction": {
        "enum": [
          "Verify",
          "Match"
        ],
        "type": "string",
        "example": "Verify"
      },
      "CisVerifySubcontractorsExecutionStateDto": {
        "type": "object",
        "properties": {
          "taxMonthEnd": {
            "type": "string",
            "description": "The 5th the tax month ends on",
            "format": "date"
          },
          "organisationCode": {
            "type": "string",
            "description": "The client's CIS Manager organisation (its tenant code)",
            "nullable": true
          },
          "requestedAt": {
            "type": "string",
            "description": "UTC time the verification requests were last sent; null when none was needed",
            "format": "date-time",
            "nullable": true
          },
          "requested": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the subcontractors HMRC was asked to verify",
            "nullable": true
          },
          "verified": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the subcontractors paid in the month who are verified",
            "nullable": true
          },
          "failed": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CisSubcontractorIssueDto"
            },
            "description": "The subcontractors HMRC could not verify, with HMRC's message",
            "nullable": true
          },
          "needDetails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CisSubcontractorIssueDto"
            },
            "description": "The subcontractors CIS Manager could not send to HMRC because their details are missing, with what is missing",
            "nullable": true
          },
          "ratesAppliedAt": {
            "type": "string",
            "description": "UTC time the verified rates were applied to the month's payments; null until every subcontractor is verified",
            "format": "date-time",
            "nullable": true
          },
          "invoicesRerated": {
            "type": "integer",
            "description": "The number of the month's invoices re-rated to their subcontractor's verified rate",
            "format": "int32"
          },
          "invoicesNotRerated": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CisInvoiceNotReratedDto"
            },
            "description": "The month's invoices whose rate differs from their subcontractor's but which CIS Manager left alone, and why",
            "nullable": true
          },
          "paidAtDifferentRate": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CisPaidAtDifferentRateDto"
            },
            "description": "The month's payments made at another rate than the one HMRC gave their subcontractor. Paid payments are never\nre-rated: the step is blocked listing them until a user acknowledges them (\"Continue anyway\")",
            "nullable": true
          },
          "rateDifferencesAcknowledgedAt": {
            "type": "string",
            "description": "UTC time a user acknowledged the payments at a different rate, which completed the step; null until then",
            "format": "date-time",
            "nullable": true
          },
          "rateDifferencesAcknowledgedByEmail": {
            "type": "string",
            "description": "Email address of the user who acknowledged the payments at a different rate",
            "nullable": true
          },
          "lastPolledAt": {
            "type": "string",
            "description": "UTC time the poll last read the subcontractors' verification",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Execution state of a Verify subcontractors step. Read-only: written by the system. The poll fills in HMRC's\nanswers and, once every subcontractor is verified, the re-rating of the month's payments."
      },
      "CisVerifySubcontractorsStepConfigDto": {
        "type": "object",
        "properties": {
          "taxMonth": {
            "$ref": "#/components/schemas/TaxMonthChoice"
          },
          "notifyAssigneeOnOutcome": {
            "type": "boolean",
            "description": "Whether to notify the step's assignee when HMRC verifies them all or cannot verify one"
          },
          "ifUnmatched": {
            "$ref": "#/components/schemas/CisUnmatchedSubcontractorAction"
          }
        },
        "additionalProperties": false,
        "description": "Configuration for Verify subcontractors workflow steps: the subcontractors paid in the tax month who are not\nverified are verified with HMRC through CIS Manager, and the rates HMRC gives are applied to the month's payments."
      },
      "Class4NicsExemptionReason": {
        "enum": [
          "Unknown",
          "NonResident",
          "Trustee",
          "Diver",
          "Ittoia2005",
          "OverStatePensionAge",
          "Under16"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "ClassifyEmailAddressesRequest": {
        "required": [
          "addresses"
        ],
        "type": "object",
        "properties": {
          "addresses": {
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The addresses to classify, at most 100. Repeats and case differences are folded together."
          }
        },
        "additionalProperties": false,
        "description": "Request to classify email addresses as a client's, not a client, the practice's own, or unknown"
      },
      "ClientAgentAuthorisationDto": {
        "type": "object",
        "properties": {
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          },
          "status": {
            "$ref": "#/components/schemas/AgentAuthorisationStatus"
          },
          "isRequired": {
            "type": "boolean",
            "description": "True if any of the client's active or proposed services require this authorisation type"
          },
          "hmrcInvitation": {
            "$ref": "#/components/schemas/HmrcInvitationDetailsDto"
          },
          "hmrcVerificationResult": {
            "$ref": "#/components/schemas/HmrcVerificationResult"
          },
          "hmrcAgentRole": {
            "$ref": "#/components/schemas/HmrcAgentRole"
          },
          "hmrcLastVerifiedDate": {
            "type": "string",
            "description": "When HMRC last answered a verification check for this authorisation.",
            "format": "date-time",
            "nullable": true
          },
          "codeEntrySource": {
            "$ref": "#/components/schemas/AuthCodeEntrySource"
          }
        },
        "additionalProperties": false,
        "description": "Represents one of the 11 HMRC agent authorisation types for a client"
      },
      "ClientApprovalStatus": {
        "enum": [
          "None",
          "Pending",
          "Approved",
          "Rejected"
        ],
        "type": "string",
        "example": "None"
      },
      "ClientAssociationType": {
        "enum": [
          "None",
          "SpecificClients",
          "AllClients",
          "ClientsWithServices",
          "ClientsWithPipelines"
        ],
        "type": "string",
        "example": "None"
      },
      "ClientBillableServiceDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this client service assignment",
            "nullable": true
          },
          "billableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "billableServiceCategory": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "recurringTaskCount": {
            "type": "integer",
            "description": "The number of recurring tasks associated with the billable service",
            "format": "int32"
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "price": {
            "type": "number",
            "description": "The base price for this client's service (before any adjustment).\nIf OverridePricing = false: Loaded from BillableService based on BillingFrequency.\nIf OverridePricing = true: Custom base price set by user.\nThe final price after adjustment is in EffectivePrice.",
            "format": "double"
          },
          "overridePricing": {
            "type": "boolean",
            "description": "Indicates whether the pricing is overridden with a custom Price value\nIf true: Price is used as-is, ignoring BillableService pricing\nIf false: Price comes from BillableService, and the client-level adjustment is applied"
          },
          "priceAdjustmentPercentage": {
            "type": "number",
            "description": "Snapshot of the percentage contribution from selected Percentage-mode pricing factors (positive or negative).",
            "format": "double"
          },
          "priceAdjustmentFixedAmount": {
            "type": "number",
            "description": "Snapshot of the absolute currency contribution from selected FixedAmount-mode pricing factors (positive or negative).",
            "format": "double"
          },
          "effectivePrice": {
            "type": "number",
            "description": "Read-only. Effective price = Price + (Price * PriceAdjustmentPercentage / 100) + PriceAdjustmentFixedAmount.\nBoth contributions are always applied — they're snapshots from different pricing factors and can coexist.\nFor non-Fixed pricing bases this is the effective rate per unit, not the amount per period.",
            "format": "double",
            "readOnly": true
          },
          "pricingBasis": {
            "$ref": "#/components/schemas/PricingBasis"
          },
          "unitName": {
            "type": "string",
            "description": "The unit label of the underlying billable service for PerUnit pricing (e.g. \"employee\")",
            "nullable": true
          },
          "unitQuantity": {
            "type": "number",
            "description": "The expected quantity per billing period for non-Fixed pricing bases (e.g. 12 employees).\nNull means the volume is unknown. Ignored when PricingBasis is Fixed.",
            "format": "double",
            "nullable": true
          },
          "quantityVariesPerPeriod": {
            "type": "boolean",
            "description": "Whether the billed quantity is expected to change from period to period. When true (default),\ngenerated billing lines for this service are always created Pending so the quantity can be\nconfirmed before invoicing, regardless of the approval settings. Ignored when PricingBasis is Fixed."
          },
          "effectivePeriodAmount": {
            "type": "number",
            "description": "Read-only. The amount charged per billing period: EffectivePrice for Fixed services,\nEffectivePrice × UnitQuantity otherwise (0 when the quantity is unknown).",
            "format": "double",
            "readOnly": true
          },
          "startDate": {
            "type": "string",
            "description": "The start date for this service",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "The end date for this service (null means ongoing)",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "managedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "effectiveManagedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "hasPreparerRole": {
            "type": "boolean",
            "description": "Whether the service has a Preparer role. When off, SodiumHQ.DTOs.ClientBillableService.ClientBillableServiceDto.PreparerUser is kept but not used."
          },
          "preparerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "effectivePreparerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "hasReviewerRole": {
            "type": "boolean",
            "description": "Whether the service has a Reviewer role. When off, SodiumHQ.DTOs.ClientBillableService.ClientBillableServiceDto.ReviewerUser is kept but not used."
          },
          "reviewerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "effectiveReviewerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "pricingAnswers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The pricing factor answers that determined the final price\nKey: Question, Value: Answer",
            "nullable": true
          },
          "pricingTierCode": {
            "type": "string",
            "description": "The code of the selected custom pricing tier. Only present when the BillableService uses CustomTiers pricing mode.",
            "nullable": true
          },
          "stage": {
            "$ref": "#/components/schemas/ClientBillableServiceStageDto"
          },
          "servicePackage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "servicePackageUsePackagePricing": {
            "type": "boolean",
            "description": "Whether the originating service package uses package-level pricing",
            "nullable": true
          },
          "servicePackagePrice": {
            "type": "number",
            "description": "The package-level price from the originating service package",
            "format": "double",
            "nullable": true
          },
          "overrideServicePackagePrice": {
            "type": "boolean",
            "description": "Whether the package-level price and billing period were agreed for this client rather than\ninherited from the package (the package-level twin of OverridePricing)"
          },
          "servicePackageBillingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "servicePackageSetupFee": {
            "type": "number",
            "description": "The package-level setup fee from the originating service package",
            "format": "double",
            "nullable": true
          },
          "setupFee": {
            "type": "number",
            "description": "The one-off setup fee for this client's service. Null means no setup fee.\nIf OverrideSetupFee = false: Mirrors the BillableService default at the time of assignment.\nIf OverrideSetupFee = true: Custom setup fee set by user.",
            "format": "double",
            "nullable": true
          },
          "overrideSetupFee": {
            "type": "boolean",
            "description": "Indicates whether the setup fee is overridden with a custom value"
          },
          "isSetupFeeBilled": {
            "type": "boolean",
            "description": "Read-only. True once the setup fee has been billed (a Billed SetupFee item exists on the\nclient's billing schedule for this service or its package)."
          },
          "autoInvoice": {
            "type": "boolean",
            "description": "Whether this service is on the billing schedule. On: occurrences are generated and due ones\nbecome billing lines nightly. Off: the service is billed outside Sodium."
          },
          "notes": {
            "type": "string",
            "description": "The practice's own notes on this client's service, as HTML. Null when there are none.",
            "nullable": true
          },
          "showNotesOnCard": {
            "type": "boolean",
            "description": "Whether the notes show on the service's card on the client's Services tab"
          },
          "setupFeeBillingMoment": {
            "$ref": "#/components/schemas/SetupFeeBillingMoment"
          },
          "billingTiming": {
            "$ref": "#/components/schemas/BillingTiming"
          },
          "defaultBillingTiming": {
            "$ref": "#/components/schemas/BillingTiming"
          },
          "effectiveBillingTiming": {
            "$ref": "#/components/schemas/BillingTiming"
          },
          "catchUp": {
            "$ref": "#/components/schemas/CatchUpFeeDto"
          },
          "overrideCatchUpFee": {
            "type": "boolean",
            "description": "Whether the catch-up fee was agreed for this client rather than worked out as the months times\nthe monthly-equivalent rate. Ignored (stored false) when there is no catch-up fee."
          },
          "nextBillingDate": {
            "type": "string",
            "description": "Read-only. The billing date of the earliest scheduled occurrence for this service (or its\npackage) on the client's billing schedule. Null when nothing is scheduled.",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the service assignment was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the service assignment was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for client billable service information"
      },
      "ClientBillableServiceDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientBillableServiceDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientBillableServiceHistoryEntryDto": {
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "string",
            "description": "When the change happened (UTC). On a HistoryStart entry for a service older than its\nhistory, the date the service was added: its values are as they stood when the history\nbegan, which may be later.",
            "format": "date-time"
          },
          "entryType": {
            "$ref": "#/components/schemas/ClientServiceHistoryEntryType"
          },
          "changedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "changedByType": {
            "$ref": "#/components/schemas/AuditUserType"
          },
          "proposal": {
            "$ref": "#/components/schemas/ClientServiceHistoryProposalDto"
          },
          "price": {
            "$ref": "#/components/schemas/ClientServiceHistoryDecimalChangeDto"
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/ClientServiceHistoryBillingFrequencyChangeDto"
          },
          "packagePrice": {
            "$ref": "#/components/schemas/ClientServiceHistoryDecimalChangeDto"
          },
          "packageBillingFrequency": {
            "$ref": "#/components/schemas/ClientServiceHistoryBillingFrequencyChangeDto"
          },
          "overridePricing": {
            "$ref": "#/components/schemas/ClientServiceHistoryBoolChangeDto"
          },
          "overridePackagePrice": {
            "$ref": "#/components/schemas/ClientServiceHistoryBoolChangeDto"
          },
          "setupFee": {
            "$ref": "#/components/schemas/ClientServiceHistoryDecimalChangeDto"
          },
          "overrideSetupFee": {
            "$ref": "#/components/schemas/ClientServiceHistoryBoolChangeDto"
          },
          "catchUpFee": {
            "$ref": "#/components/schemas/ClientServiceHistoryDecimalChangeDto"
          },
          "overrideCatchUpFee": {
            "$ref": "#/components/schemas/ClientServiceHistoryBoolChangeDto"
          },
          "quantity": {
            "$ref": "#/components/schemas/ClientServiceHistoryDecimalChangeDto"
          },
          "startDate": {
            "$ref": "#/components/schemas/ClientServiceHistoryDateChangeDto"
          },
          "endDate": {
            "$ref": "#/components/schemas/ClientServiceHistoryDateChangeDto"
          },
          "status": {
            "$ref": "#/components/schemas/ClientServiceHistoryStatusChangeDto"
          },
          "autoInvoice": {
            "$ref": "#/components/schemas/ClientServiceHistoryBoolChangeDto"
          },
          "notesChanged": {
            "type": "boolean",
            "description": "True when the service's notes were added, edited or cleared in this change. The text itself is\nnot carried: the notes on the service are the current version."
          }
        },
        "additionalProperties": false,
        "description": "One entry in a client service's change history, newest first: the fields that changed together\nin one save, who saved it, and the proposal it came from when it was a proposal's acceptance.\nA field left null did not change. On an Added or HistoryStart entry every field the service had\nis set, with a null `From`."
      },
      "ClientBillableServiceNextTaskDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The task's code, or a \"proj-\" code for an occurrence not started yet, which the task page opens",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The task name",
            "nullable": true
          },
          "dueDate": {
            "type": "string",
            "description": "When the task is due",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "A client service's next task, open or not started yet"
      },
      "ClientBillableServiceSortField": {
        "enum": [
          "Name",
          "Price"
        ],
        "type": "string",
        "example": "Name"
      },
      "ClientBillableServiceStageDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The stage code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The stage display name",
            "nullable": true
          },
          "icon": {
            "type": "string",
            "description": "Optional Lucide icon name",
            "nullable": true
          },
          "color": {
            "type": "string",
            "description": "Optional hex colour",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The stage's sort order within its service's stage progression (populated on task list responses; null elsewhere)",
            "format": "int32",
            "nullable": true
          },
          "setTime": {
            "type": "string",
            "description": "When this stage was set (UTC)",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Stage information for display on a client's billable service"
      },
      "ClientBillableServiceStageHistoryDto": {
        "type": "object",
        "properties": {
          "fromStage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "toStage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "changedBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "changedDate": {
            "type": "string",
            "description": "When the change happened (UTC).",
            "format": "date-time"
          },
          "drivenByTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "One stage change in a client billable service's history, newest first. Powers the\ntime-in-stage view: the duration a service spent in a stage is the gap between one row's\nSodiumHQ.DTOs.ClientBillableService.ClientBillableServiceStageHistoryDto.ChangedDate and the next."
      },
      "ClientBillableServiceSummaryDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this client service",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "billableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "stage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "stageSetTime": {
            "type": "string",
            "description": "When the current stage was set (UTC). Used for calculating time-in-stage on the frontend.",
            "format": "date-time",
            "nullable": true
          },
          "managedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "effectiveManagedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/KanbanTaskDto"
            },
            "description": "Open tasks for this client (not completed or skipped). Only populated in non-verbose mode.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "price": {
            "type": "number",
            "description": "The base price. Only populated when verbose=true.",
            "format": "double",
            "nullable": true
          },
          "effectivePrice": {
            "type": "number",
            "description": "The effective price after adjustments. Only populated when verbose=true.",
            "format": "double",
            "nullable": true
          },
          "overridePricing": {
            "type": "boolean",
            "description": "Whether pricing is overridden. Only populated when verbose=true.",
            "nullable": true
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "startDate": {
            "type": "string",
            "description": "The start date. Only populated when verbose=true.",
            "format": "date-time",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "The end date. Only populated when verbose=true.",
            "format": "date-time",
            "nullable": true
          },
          "autoInvoice": {
            "type": "boolean",
            "description": "Whether auto-invoicing is enabled. Only populated when verbose=true.",
            "nullable": true
          },
          "nextBillingDate": {
            "type": "string",
            "description": "Next billing date. Only populated when verbose=true.",
            "format": "date-time",
            "nullable": true
          },
          "stageIcon": {
            "type": "string",
            "description": "Stage icon (Lucide icon name). Only populated when verbose=true.",
            "nullable": true
          },
          "stageColor": {
            "type": "string",
            "description": "Stage colour (hex). Only populated when verbose=true.",
            "nullable": true
          },
          "preparerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "reviewerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "effectivePreparerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "effectiveReviewerUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "vatReportingPeriod": {
            "$ref": "#/components/schemas/VatReportingPeriod"
          },
          "nextStatutoryDueDate": {
            "type": "string",
            "description": "The earliest statutory due date among this service's open tasks and the occurrences not started yet (up to\n13 months ahead), null when none has one. Only populated when verbose=true.",
            "format": "date",
            "nullable": true
          },
          "nextStatutoryTaskCode": {
            "type": "string",
            "description": "The code of the task the next statutory due date comes from: a task's own code, or a projected\noccurrence's \"proj-\" code, which the task page opens. Only populated when verbose=true.",
            "nullable": true
          },
          "nextTask": {
            "$ref": "#/components/schemas/ClientBillableServiceNextTaskDto"
          }
        },
        "additionalProperties": false,
        "description": "Lightweight projection of a client billable service for kanban board cards.\nContains only the fields needed for board display — not the full ClientBillableServiceDto."
      },
      "ClientBillableServiceSummaryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientBillableServiceSummaryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientBillableServiceSummarySortField": {
        "enum": [
          "ClientName",
          "StageSetTime",
          "DueDate",
          "StatutoryDueDate"
        ],
        "type": "string",
        "example": "ClientName"
      },
      "ClientBillingLineItemDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this line item",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "clientBillableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "servicePackage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "description": {
            "type": "string",
            "description": "The invoice line description",
            "nullable": true
          },
          "quantity": {
            "type": "number",
            "description": "The quantity",
            "format": "double"
          },
          "unitPrice": {
            "type": "number",
            "description": "Snapshot of the effective price at generation",
            "format": "double"
          },
          "vatRate": {
            "$ref": "#/components/schemas/VatRate"
          },
          "accountingCode": {
            "type": "string",
            "description": "The accounting/nominal code",
            "nullable": true
          },
          "periodStart": {
            "type": "string",
            "description": "Start of the service period covered",
            "format": "date-time",
            "nullable": true
          },
          "periodEnd": {
            "type": "string",
            "description": "End of the service period covered",
            "format": "date-time",
            "nullable": true
          },
          "generatedDate": {
            "type": "string",
            "description": "When the line item was generated",
            "format": "date-time"
          },
          "billingDate": {
            "type": "string",
            "description": "Target invoice date",
            "format": "date-time"
          },
          "status": {
            "$ref": "#/components/schemas/ClientBillingLineItemStatus"
          },
          "invoiceSubmissionCode": {
            "type": "string",
            "description": "The invoice submission code this was bundled into (null until invoiced)",
            "nullable": true
          },
          "timeEntryCount": {
            "type": "integer",
            "description": "How many time entries were billed on this line. Non-zero means the line is derived from\ntime: its quantity and unit price are locked, and it is undone by deleting it.",
            "format": "int32"
          },
          "scheduleItemCode": {
            "type": "string",
            "description": "The billing schedule item this line was promoted from. Null for manual and time-derived\nlines. A schedule-promoted line is bound to the service or package it was generated from.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the line item was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the line item was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a billable line item"
      },
      "ClientBillingLineItemDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientBillingLineItemDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientBillingLineItemSortField": {
        "enum": [
          "BillingDate",
          "GeneratedDate",
          "Status",
          "UnitPrice"
        ],
        "type": "string",
        "example": "BillingDate"
      },
      "ClientBillingLineItemStatus": {
        "enum": [
          "Pending",
          "Approved",
          "Invoiced",
          "Cancelled"
        ],
        "type": "string",
        "example": "Pending"
      },
      "ClientBillingScheduleItemDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this schedule item",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "clientBillableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "servicePackage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "kind": {
            "$ref": "#/components/schemas/BillingScheduleItemKind"
          },
          "periodStart": {
            "type": "string",
            "description": "Start of the service period covered",
            "format": "date"
          },
          "periodEnd": {
            "type": "string",
            "description": "End of the service period covered",
            "format": "date"
          },
          "instalmentNumber": {
            "type": "integer",
            "description": "Catch-up fees only: which instalment of the fee this occurrence bills (1..N). Null for every\nother kind.",
            "format": "int32",
            "nullable": true
          },
          "billingDate": {
            "type": "string",
            "description": "Planned invoice date, already snapped to the client's invoice day",
            "format": "date"
          },
          "quantity": {
            "type": "number",
            "description": "The quantity this occurrence will bill (pinned, or the rule's current line quantity)",
            "format": "double"
          },
          "unitPrice": {
            "type": "number",
            "description": "The unit price this occurrence will bill at (pinned, or the rule's current effective price)",
            "format": "double"
          },
          "amount": {
            "type": "number",
            "description": "Quantity × unit price",
            "format": "double",
            "readOnly": true
          },
          "description": {
            "type": "string",
            "description": "The description the invoice line will carry: the pinned description where one was set,\notherwise the one derived from the rule's template, resolved as of the billing date",
            "nullable": true
          },
          "isOverridden": {
            "type": "boolean",
            "description": "A user pinned the description, quantity or unit price on this occurrence, so it no longer\nfollows the service's billing rule for them"
          },
          "status": {
            "$ref": "#/components/schemas/BillingScheduleItemStatus"
          },
          "displayStatus": {
            "$ref": "#/components/schemas/BillingScheduleDisplayStatus"
          },
          "billingLineItemCode": {
            "type": "string",
            "description": "The billing line created from this occurrence, once Billed",
            "nullable": true
          },
          "isEdited": {
            "type": "boolean",
            "description": "A user changed the date, amount or description of this occurrence"
          },
          "createdDate": {
            "type": "string",
            "description": "When the item was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the item was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One planned charge on a client's billing schedule. Amounts are the effective values: the pinned\nvalue where a user set one, otherwise the rule's current price and quantity."
      },
      "ClientBillingScheduleItemDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientBillingScheduleItemDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientBillingScheduleSortField": {
        "enum": [
          "BillingDate",
          "PeriodStart"
        ],
        "type": "string",
        "example": "BillingDate"
      },
      "ClientBillingSettingsDto": {
        "type": "object",
        "properties": {
          "clientBillingEnabled": {
            "type": "boolean",
            "description": "Whether recurring client billing features are enabled for this tenant"
          },
          "defaultInvoiceDayOfMonth": {
            "type": "integer",
            "description": "Default day of month (1-28) for automatic invoicing on new clients",
            "format": "int32",
            "nullable": true
          },
          "defaultInvoicePaymentTermDays": {
            "type": "integer",
            "description": "Default payment terms in days for generated invoices on new clients",
            "format": "int32",
            "nullable": true
          },
          "defaultLineItemApprovalRequired": {
            "type": "boolean",
            "description": "Default for whether generated line items require manual approval before invoicing on new clients"
          },
          "defaultAccountingCode": {
            "type": "string",
            "description": "Default accounting/nominal code for new billable services and manual line items",
            "nullable": true
          },
          "syncClientDetailsToAccountingConnection": {
            "type": "boolean",
            "description": "Whether client detail changes are pushed to the tenant's connected accounting platform"
          },
          "defaultSetupFeeBillingMoment": {
            "$ref": "#/components/schemas/SetupFeeBillingMoment"
          },
          "defaultCatchUpBillingMoment": {
            "$ref": "#/components/schemas/SetupFeeBillingMoment"
          },
          "createInvoicesAsDrafts": {
            "type": "boolean",
            "description": "Whether invoices Sodium raises in the accounting platform are left as drafts for review there\nrather than approved on creation. Only platforms with a draft state honour it."
          },
          "emailInvoicesToClients": {
            "type": "boolean",
            "description": "Whether invoices Sodium raises are then emailed to the client by the accounting platform.\nOnly platforms with a send endpoint honour it, and it cannot be combined with\nSodiumHQ.DTOs.Invoicing.ClientBillingSettingsDto.CreateInvoicesAsDrafts."
          }
        },
        "additionalProperties": false,
        "description": "Tenant-level settings for recurring client billing and invoicing defaults"
      },
      "ClientBookkeepingLinkDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The link's own code.",
            "nullable": true
          },
          "organisation": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "connection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "platform": {
            "type": "string",
            "description": "The bookkeeping-health platform (e.g. \"XenonConnect\").",
            "nullable": true
          },
          "connectionStatus": {
            "$ref": "#/components/schemas/ConnectionStatus"
          },
          "createdDate": {
            "type": "string",
            "description": "When the client was linked to this organisation.",
            "format": "date-time"
          },
          "externalUrl": {
            "type": "string",
            "description": "A link straight into the organisation's page on the provider's own site, or null when the\nprovider has no addressable page per organisation.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The organisation a client's record is bound to at the practice's bookkeeping-health provider,\nand the connection the practice reaches it through."
      },
      "ClientBooksLinkDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The link's own code.",
            "nullable": true
          },
          "organisation": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "connection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "platform": {
            "type": "string",
            "description": "The accounting platform (e.g. \"Xero\", \"QuickBooks\").",
            "nullable": true
          },
          "connectionStatus": {
            "$ref": "#/components/schemas/ConnectionStatus"
          },
          "isOrganisationGranted": {
            "type": "boolean",
            "description": "Whether the connection's grant still reaches this organisation. False when the client has\nremoved Sodium from their own books, or the practice reauthorised the connection without\ngranting this organisation: the connection is fine, this link is not, and the books cannot\nbe read until the client is linked again."
          },
          "createdDate": {
            "type": "string",
            "description": "When the client was linked to this organisation.",
            "format": "date-time"
          },
          "externalUrl": {
            "type": "string",
            "description": "A link straight into this organisation's own dashboard on its platform, where the platform\ncan target one organisation specifically. Null on QuickBooks and Sage.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The organisation a client's record is bound to in that client's own accounting software, and\nthe connection the practice reaches it through."
      },
      "ClientBudgetMode": {
        "enum": [
          "Standard",
          "StandardAdjusted",
          "None"
        ],
        "type": "string",
        "example": "Standard"
      },
      "ClientConfirmationDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The workflow step ID",
            "format": "int32"
          },
          "stepName": {
            "type": "string",
            "description": "The name of the workflow step",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "taskCategory": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "groupName": {
            "type": "string",
            "description": "The workflow group name",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the confirmation step was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the confirmation step was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Summary DTO for a client confirmation workflow step"
      },
      "ClientConfirmationDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientConfirmationDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientConfirmationExecutionStateDto": {
        "type": "object",
        "properties": {
          "createdAt": {
            "type": "string",
            "description": "UTC timestamp of when the confirmation email was sent.",
            "format": "date-time"
          },
          "confirmedAt": {
            "type": "string",
            "description": "UTC timestamp of when the client confirmed.",
            "format": "date-time",
            "nullable": true
          },
          "confirmedByEmail": {
            "type": "string",
            "description": "Email address of the recipient who confirmed (from magic link token).",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Execution state for a ClientConfirmation workflow step.\nRead-only - written by the system during step execution."
      },
      "ClientConfirmationSortField": {
        "enum": [
          "StepName",
          "CreatedDate",
          "Date"
        ],
        "type": "string",
        "example": "StepName"
      },
      "ClientConfirmationStepConfigDto": {
        "required": [
          "buttonText",
          "messageHtml",
          "thankYouMessageHtml"
        ],
        "type": "object",
        "properties": {
          "subjectLine": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional email subject line override. When set, replaces the content block's subject.\nSupports Liquid template syntax (e.g., \"Action required — {{ Client.Name }}\").\nWhen null/empty, the subject from the ClientPortalSettings content block is used.",
            "nullable": true
          },
          "messageHtml": {
            "minLength": 1,
            "type": "string",
            "description": "HTML message displayed on the public confirmation page.\nSupports Liquid template syntax (e.g., {{ Client.Name }})."
          },
          "buttonText": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "Text for the confirmation button on the public page."
          },
          "thankYouMessageHtml": {
            "minLength": 1,
            "type": "string",
            "description": "HTML message displayed after the client confirms.\nSupports Liquid template syntax."
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to send the confirmation email to the client's business email\n(the email address on the client record)."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types to send the confirmation email to.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to send the confirmation email to.",
            "nullable": true
          },
          "notifyAssigneeOnConfirmation": {
            "type": "boolean",
            "description": "Whether to send a notification to the step's assigned user when the client confirms."
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for how often (in days) to chase this confirmation.\nWhen null, the tenant-level default is used.",
            "format": "int32",
            "nullable": true
          },
          "alsoSendText": {
            "type": "boolean",
            "description": "Also text each email recipient who is one of the client's contacts with a mobile, by SMS, with the same link as\ntheir email, worded by the practice's text wording for this kind of request. Ignored while the practice's\nmessaging is not Active."
          },
          "senderSource": {
            "$ref": "#/components/schemas/WorkflowEmailSenderSource"
          },
          "senderMailboxCode": {
            "maxLength": 50,
            "type": "string",
            "description": "The email connection to send from when SenderSource is SpecificMailbox. Ignored otherwise,\nand required when SenderSource is SpecificMailbox.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for ClientConfirmation workflow steps.\nEmail template is configured in ClientPortalSettings, not per-step."
      },
      "ClientContactDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this relationship (uses the contact's code)",
            "nullable": true
          },
          "role": {
            "type": "string",
            "description": "The role of the contact within this client relationship",
            "nullable": true
          },
          "resignedDate": {
            "type": "string",
            "description": "Date the contact resigned their officer role for this client (from Companies House).\nNull while still an active officer.",
            "format": "date",
            "nullable": true
          },
          "ceasedDate": {
            "type": "string",
            "description": "Date the contact ceased being a Person with Significant Control for this client\n(from Companies House). Null while still an active PSC. Independent of resignation —\na person can hold both roles and end them on different dates.",
            "format": "date",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "The type of contact relationship",
            "nullable": true
          },
          "contact": {
            "$ref": "#/components/schemas/ContactDto"
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "individualClient": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "hasPortalAccess": {
            "type": "boolean",
            "description": "Whether this contact has access to the client portal for this client."
          },
          "amlContactId": {
            "type": "string",
            "description": "The contact's ID in the AML platform. Null if not yet pushed.",
            "nullable": true
          },
          "lastPortalAccessDate": {
            "type": "string",
            "description": "When this contact last accessed the client portal for this client.",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the relationship was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the relationship was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for client-contact relationship information"
      },
      "ClientContactDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientContactSortField": {
        "enum": [
          "Name",
          "Role"
        ],
        "type": "string",
        "example": "Name"
      },
      "ClientContactType": {
        "enum": [
          "Main",
          "Billing",
          "Payroll",
          "Accounts",
          "Director",
          "Psc",
          "Secretary",
          "Trustee"
        ],
        "type": "string",
        "example": "Main"
      },
      "ClientCsvTargetField": {
        "enum": [
          "Name",
          "Code",
          "Type",
          "Status",
          "Email",
          "Telephone",
          "InternalReference",
          "CanContactPost",
          "CanContactTelephone",
          "CanContactEmail",
          "CanContactSms",
          "PclSent",
          "Manager",
          "Partner",
          "Associate",
          "CompanyNumber",
          "CompaniesHouseAuthenticationCode",
          "VatNumber",
          "VatRegistered",
          "VatRegDate",
          "VatScheme",
          "VatReportingPeriod",
          "Utr",
          "SelfAssessmentUtr",
          "CompanyUtr",
          "NiNumber",
          "PayeRef",
          "AccountsOfficeRef",
          "TradingAs",
          "NatureOfBusiness",
          "IncorporationDate",
          "RegisteredAddress",
          "PostalAddress",
          "InvoiceAddress",
          "RegisteredAddressLine1",
          "RegisteredAddressLine2",
          "RegisteredAddressLine3",
          "RegisteredAddressCity",
          "RegisteredAddressPostCode",
          "RegisteredAddressCountry",
          "PostalAddressLine1",
          "PostalAddressLine2",
          "PostalAddressLine3",
          "PostalAddressCity",
          "PostalAddressPostCode",
          "PostalAddressCountry",
          "InvoiceAddressLine1",
          "InvoiceAddressLine2",
          "InvoiceAddressLine3",
          "InvoiceAddressCity",
          "InvoiceAddressPostCode",
          "InvoiceAddressCountry",
          "ContactName",
          "ContactTitle",
          "ContactFirstName",
          "ContactMiddleName",
          "ContactLastName",
          "ContactEmail",
          "ContactPhone",
          "ContactMobile",
          "ContactDateOfBirth",
          "PersonalCode",
          "ContactRelationships",
          "Team",
          "Website",
          "ContactNationality",
          "ContactMaritalStatus",
          "ContactAddress",
          "VatPeriodEnd",
          "Notes",
          "ImportantNotes",
          "SicCodes",
          "DateOfTrading",
          "TradingAsSoleTrader",
          "LinkedInUrl",
          "FacebookUrl",
          "TwitterUrl",
          "InstagramUrl",
          "AuthSelfAssessment",
          "AuthCorporationTax",
          "AuthPayeForEmployers",
          "AuthIndividualPayAsYouEarn",
          "AuthVat",
          "AuthConstructionIndustryScheme",
          "AuthTaxCredits",
          "AuthHighIncomeChildBenefitCharge",
          "AuthMakingTaxDigitalIncomeTax",
          "AuthMakingTaxDigitalVat",
          "AuthTrusts",
          "AmlClientId",
          "Notes2",
          "Notes3",
          "Notes4",
          "Notes5",
          "VatFlatRateScheme",
          "AmlContactId",
          "RelatedClientName",
          "ContactIsPrimary",
          "ContactJobTitle",
          "RegisteredAddressCounty",
          "PostalAddressCounty",
          "InvoiceAddressCounty",
          "ContactPreferredName",
          "CanContactWhatsApp",
          "CharityNumber",
          "IsCharity",
          "VatFrequency",
          "XeroCustomerId",
          "AdfinCustomerId",
          "AdditionalEmails",
          "AdditionalPhoneNumbers",
          "ContactAdditionalEmails",
          "ContactAdditionalPhoneNumbers",
          "CgtReference"
        ],
        "type": "string",
        "example": "Name"
      },
      "ClientDateDto": {
        "type": "object",
        "properties": {
          "dateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "date": {
            "type": "string",
            "description": "The actual date value for this client date type",
            "format": "date",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional additional notes or context about this date",
            "nullable": true
          },
          "isComputed": {
            "type": "boolean",
            "description": "True when the date is auto-calculated from the client's VAT reporting period and cannot be edited"
          }
        },
        "additionalProperties": false,
        "description": "Represents an important date associated with a client, such as year-end, accounts due date, or VAT return date.\nThese dates are used for scheduling recurring tasks and compliance deadlines specific to the client's accounting calendar."
      },
      "ClientDateSourceType": {
        "enum": [
          "KeyDate",
          "CustomField"
        ],
        "type": "string",
        "example": "KeyDate"
      },
      "ClientDateType": {
        "enum": [
          "IncorporationDate",
          "YearEnd",
          "AccountsNextDue",
          "AccountsNextPeriodStart",
          "AccountsNextPeriodEnd",
          "AccountsLastPeriodFiled",
          "AccountsLastPeriodStart",
          "AccountsLastPeriodEnd",
          "AccountsLastMadeUpTo",
          "ConfirmationStatementDue",
          "ConfirmationStatementNextMadeUpTo",
          "LastConfirmationStatementFiled",
          "LastConfirmationStatementMadeUpTo",
          "NextVatReturnDueAnnual",
          "NextVatPeriodEndQuarterly",
          "NextVatReturnDueQuarterly",
          "NextVatPeriodEndMonthly",
          "NextVatReturnDueMonthly",
          "NextTaxQuarterPeriodEnd",
          "NextTaxQuarterSubmissionDeadline",
          "NextPayeCisFilingDue",
          "PensionReEnrolmentDate",
          "CharityAnnualReturnDue",
          "CharityAccountsDue",
          "CharityLastAnnualReturnReceived",
          "CharityLastAccountsReceived",
          "CharityFinancialYearEnd"
        ],
        "type": "string",
        "example": "IncorporationDate"
      },
      "ClientDeadlineDateDto": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "The date the deadlines fall on",
            "format": "date"
          },
          "totalCount": {
            "type": "integer",
            "description": "Total number of client deadlines on this date, across all types",
            "format": "int32"
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientDeadlineGroupDto"
            },
            "description": "One entry per deadline type with at least one client on this date, in key-date order",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The statutory deadlines that fall on one date, grouped by deadline type"
      },
      "ClientDeadlineGroupDto": {
        "type": "object",
        "properties": {
          "dateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "count": {
            "type": "integer",
            "description": "Number of clients with this deadline on the date",
            "format": "int32"
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The clients with this deadline on the date, ordered by name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The clients with one type of statutory deadline on a date"
      },
      "ClientDocumentApprovalDto": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ClientApprovalStatus"
          },
          "method": {
            "$ref": "#/components/schemas/DocumentApprovalMethod"
          },
          "requestedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "requestedDate": {
            "type": "string",
            "description": "When client approval was requested",
            "format": "date-time",
            "nullable": true
          },
          "contact": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "email": {
            "type": "string",
            "description": "Email address of the recipient who approved or rejected (from magic link token).",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "When the client approved or rejected this document",
            "format": "date-time",
            "nullable": true
          },
          "note": {
            "type": "string",
            "description": "Note provided by the client when approving or rejecting",
            "nullable": true
          },
          "ipAddress": {
            "type": "string",
            "description": "IP address of the client who approved or rejected this document",
            "nullable": true
          },
          "batchCode": {
            "type": "string",
            "description": "Code of the approval batch this document was sent in, if any. Present for historic batches\ntoo — combine with BatchStatus and Status to tell whether the batch decision is still\noutstanding.",
            "nullable": true
          },
          "batchStatus": {
            "$ref": "#/components/schemas/DocumentApprovalBatchStatus"
          },
          "batchDocumentCount": {
            "type": "integer",
            "description": "How many documents the batch was sent with. A single-document request is a batch of one,\nso this is what tells \"sent on its own\" from \"sent alongside others\" — never BatchCode.",
            "format": "int32",
            "nullable": true
          },
          "signature": {
            "$ref": "#/components/schemas/ClientDocumentSignatureDto"
          },
          "chase": {
            "$ref": "#/components/schemas/ChaseScheduleDto"
          }
        },
        "additionalProperties": false,
        "description": "The client's sign-off on a document: whether it was asked for, how it was asked for, who\nanswered and what they said, plus the chase schedule while it is outstanding.\n            \nAlways present — SodiumHQ.DTOs.ClientDocument.ClientDocumentApprovalDto.Status is None for a document never sent for approval. Not to\nbe confused with the document's ReviewStatus, which is the practice's own internal check."
      },
      "ClientDocumentDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this document",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "category": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "title": {
            "type": "string",
            "description": "The title of the document",
            "nullable": true
          },
          "summary": {
            "type": "string",
            "description": "A brief summary or description of the document",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "The date the document is dated (not the creation date)",
            "format": "date"
          },
          "file": {
            "$ref": "#/components/schemas/ClientDocumentFileDto"
          },
          "approval": {
            "$ref": "#/components/schemas/ClientDocumentApprovalDto"
          },
          "reviewStatus": {
            "$ref": "#/components/schemas/ReviewStatus"
          },
          "uploadedByContact": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "reviewedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "reviewedDate": {
            "type": "string",
            "description": "When this document was reviewed",
            "format": "date-time",
            "nullable": true
          },
          "visibleInClientPortal": {
            "type": "boolean",
            "description": "Whether this document is visible to the client in the portal.\nDoes not affect visibility in external storage providers — only controls portal access."
          },
          "portalFolderPath": {
            "type": "string",
            "description": "Folder path controlling where this document appears in the client portal.\nFormat: \"/\" separated folder names, e.g. \"Tax Returns/2026\".\nNull for root-level documents.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the document record was created in the system",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the document record was last updated",
            "format": "date-time",
            "nullable": true
          },
          "clientNotifiedDate": {
            "type": "string",
            "description": "When the client was last notified about this document. Null if never notified.",
            "format": "date-time",
            "nullable": true
          },
          "clientNotifiedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "documentRequest": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "taskCategory": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "Represents a document associated with a client, such as letters, engagement letters, proposals, or other correspondence.\nDocuments may be stored in blob storage or an external platform (e.g., Google Drive).\n            \nThe two things a document is \"waiting on\" are deliberately separate objects: SodiumHQ.DTOs.ClientDocument.ClientDocumentDto.File\nfor the bytes, and SodiumHQ.DTOs.ClientDocument.ClientDocumentDto.Approval for the client's sign-off. The practice's own internal\ncheck stays at the top level as ReviewStatus — it is a different vocabulary from the client's\napproval and the two are easily confused when they sit side by side."
      },
      "ClientDocumentDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientDocumentDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientDocumentEditableHtmlDto": {
        "type": "object",
        "properties": {
          "html": {
            "type": "string",
            "description": "The body HTML, with tokens resolved and images showing.",
            "nullable": true
          },
          "designThemeCode": {
            "type": "string",
            "description": "Code of the design theme the document will use, so the editor can show its styling. Null when the practice has no\ntheme to use.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A document template's body with the client's data filled in, ready to edit before the document is created."
      },
      "ClientDocumentFileDto": {
        "type": "object",
        "properties": {
          "originalFileName": {
            "type": "string",
            "description": "Original file name provided during upload",
            "nullable": true
          },
          "contentType": {
            "type": "string",
            "description": "MIME type of the document (e.g., application/pdf)",
            "nullable": true
          },
          "fileSize": {
            "type": "integer",
            "description": "File size in bytes",
            "format": "int64"
          },
          "storageType": {
            "$ref": "#/components/schemas/StorageType"
          },
          "downloadUrl": {
            "type": "string",
            "description": "URL for downloading/viewing the document.\nFor Azure Blob: a time-limited SAS URL.\nFor External: a link to the file in the external platform.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The physical file behind a client document — what it is called, what it weighs, where it\nlives and how to fetch it. Always present, even for documents whose bytes sit in an external\nstorage provider rather than our own blob storage."
      },
      "ClientDocumentPortalViewResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientDocumentDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          },
          "folders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortalFolderDto"
            },
            "description": "Sub-folders at the current navigation level. Empty when there are no sub-folders.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Paginated list of client documents with portal folder navigation, as seen by the client.\nUsed by the \"Portal View\" preview in the main web app."
      },
      "ClientDocumentSignatureDto": {
        "type": "object",
        "properties": {
          "platform": {
            "type": "string",
            "description": "The signing platform handling the bundle, e.g. \"FuseSign\".",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/SignatureRequestStatus"
          },
          "signingUrl": {
            "type": "string",
            "description": "The platform's signing page for the bundle, when it reported one. Null when the platform\ngave no link — those requests are not chased, since a magic link would offer a tick-box\nroute around signing.",
            "nullable": true
          },
          "draftUrl": {
            "type": "string",
            "description": "The platform's editing page while the bundle is a draft: the practice still has to place\nthe signature fields there and send it. Only set while Status is Draft.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The e-signature leg of a document's approval, when the practice sent it to a signing\nplatform instead of asking for a portal tick box. Null on portal approvals."
      },
      "ClientDocumentSortField": {
        "enum": [
          "Title",
          "Date",
          "UpdatedDate",
          "CreatedDate"
        ],
        "type": "string",
        "example": "Title"
      },
      "ClientDocumentVersionDto": {
        "type": "object",
        "properties": {
          "versionId": {
            "type": "string",
            "description": "The provider's own identifier for this revision. Opaque — pass it back to download this\nrevision, never parse or order by it.",
            "nullable": true
          },
          "isCurrent": {
            "type": "boolean",
            "description": "Whether this is the file the document currently serves."
          },
          "modifiedDate": {
            "type": "string",
            "description": "When the provider recorded this revision.",
            "format": "date-time"
          },
          "fileSize": {
            "type": "integer",
            "description": "Size in bytes, 0 where the provider does not report one.",
            "format": "int64"
          },
          "modifiedBy": {
            "type": "string",
            "description": "Who saved this revision, as the provider names them. Null where the provider does not say —\nDropbox reports no author on a revision.",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "description": "The file's name at this revision, where the provider records one per revision.",
            "nullable": true
          },
          "downloadUrl": {
            "type": "string",
            "description": "Time-limited signed URL streaming this revision's file.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One earlier or current file in a document's version history, as the practice's storage provider\nkeeps it. Sodium stores no copies of superseded files: this list is read live from the provider\neach time it is asked for, so it shows exactly what that account has actually retained. A\ndocument not held on a provider that keeps versions has no history at all."
      },
      "ClientDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The client's unique Code within the tenant",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The name of the client",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/ClientType"
          },
          "manager": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "partner": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "associate": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "teams": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The teams assigned to this client",
            "nullable": true
          },
          "isAccessRestricted": {
            "type": "boolean",
            "description": "When true, only the people in AccessUsers may see this client (on top of the usual visibility rule)"
          },
          "accessUsers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The people who may see this client while its access is restricted; empty when it is not",
            "nullable": true
          },
          "internalReference": {
            "type": "string",
            "description": "Optional internal reference number/code for the client",
            "nullable": true
          },
          "revenueRangeCode": {
            "type": "string",
            "description": "The revenue range code for this client",
            "nullable": true
          },
          "revenueRangeName": {
            "type": "string",
            "description": "The name of the client's revenue range. Null when none is set.\nUsage in templates: {{ Client.RevenueRangeName }}",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ClientStatus"
          },
          "accountingCustomerCode": {
            "type": "string",
            "description": "The customer code/ID from the connected accounting platform",
            "nullable": true
          },
          "directDebitMandateId": {
            "type": "string",
            "description": "The mandate ID from the connected direct debit platform",
            "nullable": true
          },
          "amlClientId": {
            "type": "string",
            "description": "The client/account ID from the connected AML platform",
            "nullable": true
          },
          "amlClientName": {
            "type": "string",
            "description": "The display name of the client in the connected AML platform",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The email address for the client",
            "nullable": true
          },
          "alternativeEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional email addresses for the client. Email remains the primary address.",
            "nullable": true
          },
          "telephone": {
            "type": "string",
            "description": "The telephone number for the client",
            "nullable": true
          },
          "alternativePhoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional phone numbers for the client. Telephone remains the primary number.",
            "nullable": true
          },
          "logoUrl": {
            "type": "string",
            "description": "Public web address of the client's logo, or null when the client has none and the\ngenerated badge is shown. Changed with the logo endpoints, not the client update.",
            "nullable": true
          },
          "logoSource": {
            "$ref": "#/components/schemas/ClientLogoSource"
          },
          "logoCheckedAtUtc": {
            "type": "string",
            "description": "When the automatic logo lookup last ran for this client, or null if it never has.",
            "format": "date-time",
            "nullable": true
          },
          "contactPreferences": {
            "$ref": "#/components/schemas/ContactPreferencesDto"
          },
          "invoiceDayOfMonth": {
            "type": "integer",
            "description": "Day of month (1-28) for automatic invoicing. Null disables auto-invoicing.",
            "format": "int32",
            "nullable": true
          },
          "invoicePaymentTermDays": {
            "type": "integer",
            "description": "Payment terms in days for generated invoices",
            "format": "int32",
            "nullable": true
          },
          "lineItemApprovalRequired": {
            "type": "boolean",
            "description": "Null = use tenant default. True = require manual approval. False = auto-approve.",
            "nullable": true
          },
          "vatTreatment": {
            "$ref": "#/components/schemas/ClientVatTreatment"
          },
          "primaryContactName": {
            "type": "string",
            "description": "The full name of the primary (main) contact for this client",
            "nullable": true
          },
          "primaryContactEmail": {
            "type": "string",
            "description": "The email address of the primary (main) contact for this client",
            "nullable": true
          },
          "tradingAs": {
            "type": "string",
            "description": "The client's trading name (from its business details)",
            "nullable": true
          },
          "vatScheme": {
            "$ref": "#/components/schemas/VatScheme"
          },
          "latestNoteContent": {
            "type": "string",
            "description": "The most recent note/comment on this client",
            "nullable": true
          },
          "latestNoteDate": {
            "type": "string",
            "description": "When the most recent note was created",
            "format": "date-time",
            "nullable": true
          },
          "pinnedNoteContent": {
            "type": "string",
            "description": "The most prominently pinned note on this client (highest pin level, then most recent)",
            "nullable": true
          },
          "pinnedNoteDate": {
            "type": "string",
            "description": "When the pinned note was created",
            "format": "date-time",
            "nullable": true
          },
          "pclSent": {
            "type": "boolean",
            "description": "Indicates whether a Professional Clearance Letter has been sent for this client"
          },
          "snoozeChasesUntil": {
            "type": "string",
            "description": "Automated chase emails are suppressed until this date (chasing resumes on the date itself). Null = not snoozed.",
            "format": "date-time",
            "nullable": true
          },
          "companiesHouseLastSyncedDate": {
            "type": "string",
            "description": "When Companies House data was last synced for this client",
            "format": "date-time",
            "nullable": true
          },
          "documentsPendingClientApprovalCount": {
            "type": "integer",
            "description": "Number of documents awaiting client approval",
            "format": "int32"
          },
          "documentsPendingUserReviewCount": {
            "type": "integer",
            "description": "Number of documents uploaded by client via portal awaiting user review",
            "format": "int32"
          },
          "portalUserCount": {
            "type": "integer",
            "description": "Number of portal users with access to this client",
            "format": "int32"
          },
          "outstandingDocumentRequestCount": {
            "type": "integer",
            "description": "Number of document requests in Open or Submitted status",
            "format": "int32"
          },
          "documentRequestsPendingReviewCount": {
            "type": "integer",
            "description": "Number of document requests in Submitted status awaiting staff review",
            "format": "int32"
          },
          "pendingConfirmationCount": {
            "type": "integer",
            "description": "Number of client confirmation workflow steps awaiting the client's response",
            "format": "int32"
          },
          "pendingBillingLineItemCount": {
            "type": "integer",
            "description": "Number of billing line items waiting for someone to approve them",
            "format": "int32"
          },
          "failedInvoiceSubmissionCount": {
            "type": "integer",
            "description": "Number of invoice submissions that failed to reach the accounting platform",
            "format": "int32"
          },
          "keyDates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientDateDto"
            },
            "description": "The client's key dates. Populated on list responses only (single-client reads use the\ndedicated key dates endpoint). Includes the engine-computed VAT dates, flagged with\nisComputed — those are derived from the client's VAT reporting period, not stored.",
            "nullable": true
          },
          "missingRequiredCustomFieldCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the required custom fields that apply to this client and have no value. Populated\nonly when the list was filtered with missingRequiredData=true; empty on every other read.",
            "nullable": true
          },
          "requiredCustomFieldValues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomFieldValueDto"
            },
            "description": "Values already held for the required custom fields that apply to this client. Populated on\nthe same reads as SodiumHQ.DTOs.Client.ClientDto.MissingRequiredCustomFieldCodes. A required field in neither\nlist does not apply to this client, so there is nothing to fill in for it.",
            "nullable": true
          },
          "requiredAgentAuthorisations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentAuthorisationType"
            },
            "description": "HMRC agent authorisation types required by this client's active or proposed services.\nPopulated on single-client reads only (the list endpoint would run this per row).\nUses the same rule as the IsRequired flag on the agent authorisations endpoint.",
            "nullable": true
          },
          "requiredProducts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SodiumProduct"
            },
            "description": "Sodium products required by this client's active or proposed services: the record shows each\none's tab. Populated on single-client reads only, by the same rule as\nSodiumHQ.DTOs.Client.ClientDto.RequiredAgentAuthorisations.",
            "nullable": true
          },
          "linkedProducts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SodiumProduct"
            },
            "description": "Sodium products this client has an account in (e.g. a CIS Manager organisation). The record\nshows each one's tab whether or not a service still requires it. Single-client reads only.",
            "nullable": true
          },
          "practiceManagerUrl": {
            "type": "string",
            "description": "The client's page in Xero Practice Manager, when the client is linked to an XPM client and XPM has given its\naddress. Null otherwise. Single-client reads only.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the client was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the client was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for client information"
      },
      "ClientDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientEmailRuleDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this rule",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "value": {
            "type": "string",
            "description": "The email address, domain, or message ID to match.\nEmail addresses (contain '@') match that specific participant.\nDomains (no '@', not a GUID) match all emails from that domain.\nMessage IDs (valid GUID) pin a specific email to this client.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the rule was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the rule was last updated",
            "format": "date-time",
            "nullable": true
          },
          "isAutoAdded": {
            "type": "boolean",
            "description": "Whether this rule was automatically added from client/contact email addresses.\nAuto-added rules are maintained by the system and updated when the source email changes."
          }
        },
        "additionalProperties": false,
        "description": "A rule that associates emails with a client.\nThe value determines the matching behaviour:\nemail addresses (contain '@') match that specific participant,\ndomains (no '@', not a GUID) match all emails from that domain,\nmessage IDs (valid GUID) pin a specific email to this client.\nThe same value can be a rule for multiple clients."
      },
      "ClientEmailRuleDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientEmailRuleDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientEmailRuleSortField": {
        "enum": [
          "Value",
          "CreatedDate"
        ],
        "type": "string",
        "example": "Value"
      },
      "ClientEmailSender": {
        "enum": [
          "PracticeDefault",
          "ClientManager",
          "Sender"
        ],
        "type": "string",
        "example": "PracticeDefault"
      },
      "ClientFeeRequest": {
        "required": [
          "clientCode"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "minLength": 1,
            "type": "string",
            "description": "The client code"
          },
          "feeAmount": {
            "maximum": 100000000,
            "minimum": 0.01,
            "type": "number",
            "description": "The total to charge this client (ex VAT) for the entries in the window",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "One client's fee in a bulk billing run"
      },
      "ClientImportLinkDto": {
        "required": [
          "clientCode",
          "externalId"
        ],
        "type": "object",
        "properties": {
          "externalId": {
            "minLength": 1,
            "type": "string",
            "description": "The platform's ID for the client"
          },
          "clientCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the Sodium client it is"
          }
        },
        "additionalProperties": false,
        "description": "A platform client to link to an existing Sodium client as part of an import request"
      },
      "ClientImportRequestDto": {
        "type": "object",
        "properties": {
          "externalIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of external IDs to import from the third-party platform.\nIgnored when ImportAll is true.",
            "nullable": true,
            "example": [
              "ext-123",
              "ext-456"
            ]
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientImportLinkDto"
            },
            "description": "Platform clients to link to existing Sodium clients instead of importing, applied in order before the\nimport is queued, under the same rules as the map-client route. A link that is refused is reported in\nthe response's LinkFailures and does not stop the rest. A request with links alone queues no import.",
            "nullable": true
          },
          "importAll": {
            "type": "boolean",
            "description": "When true, imports every available client from the platform and ignores ExternalIds. Clients that match\none already in Sodium are left out for review (the job's LeftForReviewCount)."
          },
          "enrichFromCompaniesHouse": {
            "type": "boolean",
            "description": "When true, newly imported companies are enriched with Companies House data (business\ndetails, key dates, officer contacts). Individuals, sole traders, trusts and associations\nare never enriched."
          },
          "defaultClientType": {
            "$ref": "#/components/schemas/ClientType"
          }
        },
        "additionalProperties": false,
        "description": "Request to import clients from a third-party platform"
      },
      "ClientImportResponseDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for this import job",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ImportJobStatus"
          },
          "totalItems": {
            "type": "integer",
            "description": "Total number of items to be imported",
            "format": "int32",
            "nullable": true
          },
          "processedItems": {
            "type": "integer",
            "description": "Number of items processed so far",
            "format": "int32"
          },
          "successCount": {
            "type": "integer",
            "description": "Number of items successfully imported",
            "format": "int32"
          },
          "failureCount": {
            "type": "integer",
            "description": "Number of items that failed to import",
            "format": "int32"
          },
          "skippedCount": {
            "type": "integer",
            "description": "Number of items skipped because the platform client was already imported",
            "format": "int32"
          },
          "leftForReviewCount": {
            "type": "integer",
            "description": "Number of clients an Import All left out because each matches a client already in Sodium. They stay on\nthe import page, where they can be linked or imported as new.",
            "format": "int32"
          },
          "errorMessage": {
            "type": "string",
            "description": "Why the job as a whole failed. Set only when Status is Failed, and only for job-level\nfailures (deleted connection, unsupported platform, unhandled error) - per-client failure\nreasons come from the import job clients endpoint instead.",
            "nullable": true
          },
          "enrichFromCompaniesHouse": {
            "type": "boolean",
            "description": "Whether Companies House enrichment is enabled"
          },
          "defaultClientType": {
            "$ref": "#/components/schemas/ClientType"
          },
          "startedDate": {
            "type": "string",
            "description": "When the job started processing",
            "format": "date-time",
            "nullable": true
          },
          "completedDate": {
            "type": "string",
            "description": "When the job completed",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the job was created",
            "format": "date-time"
          },
          "linkedCount": {
            "type": "integer",
            "description": "How many of the request's links were made",
            "format": "int32"
          },
          "linkFailures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientLinkFailureDto"
            },
            "description": "The request's links that were refused, with why",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The answer to an import request: the import job, and what became of the links the request carried. The link\nresults are not stored, so only this response has them; the job status routes return the job alone. A request\nwith links alone queues no job, so Code is empty and Status is Completed."
      },
      "ClientInvoiceSubmissionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this submission",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "billingDate": {
            "type": "string",
            "description": "The target invoice date",
            "format": "date-time"
          },
          "submittedAt": {
            "type": "string",
            "description": "When the invoice was pushed to the platform",
            "format": "date-time",
            "nullable": true
          },
          "externalInvoiceId": {
            "type": "string",
            "description": "The invoice ID from the accounting platform",
            "nullable": true
          },
          "externalInvoiceNumber": {
            "type": "string",
            "description": "The invoice number from the accounting platform",
            "nullable": true
          },
          "externalInvoiceUrl": {
            "type": "string",
            "description": "Direct URL to view the invoice on the accounting platform",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ClientInvoiceSubmissionStatus"
          },
          "errorMessage": {
            "type": "string",
            "description": "Failure reason if push failed",
            "nullable": true
          },
          "sentToClientAt": {
            "type": "string",
            "description": "When the accounting platform emailed this invoice to the client, or null if it did not",
            "format": "date-time",
            "nullable": true
          },
          "sendError": {
            "type": "string",
            "description": "Why the invoice could not be emailed, on a submission that was otherwise raised successfully",
            "nullable": true
          },
          "lineCount": {
            "type": "integer",
            "description": "Number of line items in this submission",
            "format": "int32"
          },
          "totalAmount": {
            "type": "number",
            "description": "Total amount of all line items (Quantity × UnitPrice)",
            "format": "double"
          },
          "submittedTotal": {
            "type": "number",
            "description": "The line total at the moment the invoice was pushed to the accounting platform, pinned\nonce and never updated. Null for submissions not yet pushed, or pushed before this was\nrecorded. Anything edited on the platform afterwards is not reflected here or anywhere.",
            "format": "double",
            "nullable": true
          },
          "lineItems": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientBillingLineItemDto"
            },
            "description": "The billing line items in this submission",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the submission was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the submission was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for an invoice submission"
      },
      "ClientInvoiceSubmissionDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientInvoiceSubmissionDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientInvoiceSubmissionSortField": {
        "enum": [
          "BillingDate",
          "SubmittedAt",
          "Status",
          "TotalAmount"
        ],
        "type": "string",
        "example": "BillingDate"
      },
      "ClientInvoiceSubmissionStatus": {
        "enum": [
          "Pending",
          "Submitted",
          "Failed",
          "Projected"
        ],
        "type": "string",
        "example": "Pending"
      },
      "ClientLinkDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this link",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "The URL of the link",
            "nullable": true
          },
          "linkType": {
            "$ref": "#/components/schemas/LinkType"
          },
          "displayName": {
            "type": "string",
            "description": "Optional display name shown as anchor text instead of the URL",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the link was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the link was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for client link information"
      },
      "ClientLinkDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientLinkDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientLinkFailureDto": {
        "type": "object",
        "properties": {
          "externalId": {
            "type": "string",
            "description": "The platform's ID for the client that was not linked",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "description": "Why the link was refused",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A link from an import request that was refused"
      },
      "ClientLinkSortField": {
        "enum": [
          "LinkType"
        ],
        "type": "string",
        "example": "LinkType"
      },
      "ClientListSyncDto": {
        "type": "object",
        "properties": {
          "isEnabled": {
            "type": "boolean",
            "description": "Whether the sync is switched on."
          },
          "lastPolledDate": {
            "type": "string",
            "description": "When the poll last ran (UTC), whether or not it succeeded. Null before the first poll.",
            "format": "date-time",
            "nullable": true
          },
          "lastError": {
            "type": "string",
            "description": "Why the last poll failed, in words the practice can read; null once a poll succeeds.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A connection's two-way client list sync, for its switch: whether it is on and how the last poll went."
      },
      "ClientListSyncPreviewDto": {
        "type": "object",
        "properties": {
          "clientsToAddToSodium": {
            "type": "integer",
            "description": "Active clients on the platform not linked to a Sodium client: the clients switching on would add to Sodium.\nLink the ones that already exist on the import page first, or they are duplicated.",
            "format": "int32"
          },
          "clientsToAddToPlatform": {
            "type": "integer",
            "description": "Active Sodium clients not linked to a client on the platform: the clients switching on would add to the platform.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "What switching a connection's client list sync on would copy each way, for the confirm step. The platform's\nclients are counted live, one call per 500 of them."
      },
      "ClientLogoSource": {
        "enum": [
          "None",
          "Fetched",
          "Uploaded"
        ],
        "type": "string",
        "example": "None"
      },
      "ClientNoteSortField": {
        "enum": [
          "Date",
          "UpdatedDate"
        ],
        "type": "string",
        "example": "Date"
      },
      "ClientNotesSummaryDto": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "The summary, plain text",
            "nullable": true
          },
          "generatedBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "generatedDate": {
            "type": "string",
            "description": "When it was generated (UTC)",
            "format": "date-time"
          },
          "noteCount": {
            "type": "integer",
            "description": "How many notes the client had when it was generated",
            "format": "int32"
          },
          "isStale": {
            "type": "boolean",
            "description": "True when a note has been added, edited or deleted since it was generated"
          }
        },
        "additionalProperties": false,
        "description": "The AI summary of a client's notes"
      },
      "ClientPipelineDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this pipeline card",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "pipeline": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "stage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "stageIcon": {
            "type": "string",
            "description": "Stage icon (Lucide icon name)",
            "nullable": true
          },
          "stageColor": {
            "type": "string",
            "description": "Stage colour (hex)",
            "nullable": true
          },
          "stageSetTime": {
            "type": "string",
            "description": "When the current stage was set (UTC)",
            "format": "date-time",
            "nullable": true
          },
          "managedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "startDate": {
            "type": "string",
            "description": "The date the client entered the pipeline",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "The date the client left the pipeline (optional)",
            "format": "date-time",
            "nullable": true
          },
          "value": {
            "type": "number",
            "description": "What the deal is worth if it closes (optional)",
            "format": "double",
            "nullable": true
          },
          "likelihood": {
            "type": "integer",
            "description": "How likely the deal is to close, as a percentage 0-100 (optional)",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a client's placement on a sales pipeline (a kanban card)."
      },
      "ClientPipelineDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientPipelineDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientPipelineSortField": {
        "enum": [
          "Name",
          "StageSetTime",
          "StartDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "ClientPipelineSummaryDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this pipeline card",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "pipeline": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "stage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "stageIcon": {
            "type": "string",
            "description": "Stage icon (Lucide icon name)",
            "nullable": true
          },
          "stageColor": {
            "type": "string",
            "description": "Stage colour (hex)",
            "nullable": true
          },
          "stageSetTime": {
            "type": "string",
            "description": "When the current stage was set (UTC). Used for calculating time-in-stage on the frontend.",
            "format": "date-time",
            "nullable": true
          },
          "managedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "startDate": {
            "type": "string",
            "description": "The date the client entered the pipeline",
            "format": "date-time",
            "nullable": true
          },
          "value": {
            "type": "number",
            "description": "What the deal is worth if it closes (optional)",
            "format": "double",
            "nullable": true
          },
          "likelihood": {
            "type": "integer",
            "description": "How likely the deal is to close, as a percentage 0-100 (optional)",
            "format": "int32",
            "nullable": true
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/KanbanTaskDto"
            },
            "description": "Open tasks for this client (not completed or skipped).",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Lightweight projection of a client pipeline card for kanban board display.\nReuses SodiumHQ.DTOs.ClientBillableService.KanbanTaskDto for the open-tasks list."
      },
      "ClientPipelineSummaryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientPipelineSummaryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientPipelineSummarySortField": {
        "enum": [
          "ClientName",
          "StageSetTime",
          "DueDate"
        ],
        "type": "string",
        "example": "ClientName"
      },
      "ClientPortalSettingsDto": {
        "type": "object",
        "properties": {
          "portalTitle": {
            "type": "string",
            "description": "The title displayed on the client portal",
            "nullable": true
          },
          "designTheme": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "iconImageAsset": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "showInvoices": {
            "type": "boolean",
            "description": "Whether portal users can view their invoices. Requires the tenant to be connected to an accounting provider and the client to be mapped to an accounting client."
          },
          "showServices": {
            "type": "boolean",
            "description": "Whether portal users can view the services set up for them in Sodium, including prices and dates."
          },
          "invitationEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "useIntroPageContentBlock": {
            "type": "boolean",
            "description": "When true, the intro page uses the content block. When false, it uses IntroPageText."
          },
          "introPageContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "introPageText": {
            "type": "string",
            "description": "Raw HTML content for the intro page (when UseIntroPageContentBlock is false)",
            "nullable": true
          },
          "notifyManagerOnClientDocumentUpload": {
            "type": "boolean",
            "description": "Whether to send an email notification to the client's manager when a document is uploaded via the portal"
          },
          "url": {
            "type": "string",
            "description": "The URL for the client portal (e.g. https://tenantcode.sodiumportal.com)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Client portal settings for the tenant"
      },
      "ClientPreviewDataFormRequest": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client code to preview the form as.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a client-context preview link for a data form."
      },
      "ClientRefDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "logoUrl": {
            "type": "string",
            "description": "The client's uploaded logo URL, or null when it has none",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A reference to a client from another record: its code and name plus the logo that\nidentifies it visually (story 2607). A null logo means the client has none uploaded, so\nthe consumer shows the generated badge keyed by the code."
      },
      "ClientRequestSettingsDto": {
        "type": "object",
        "properties": {
          "documentApprovalEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "documentRequestOpenedEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "documentRequestRejectedEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "documentRequestSubmittedEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "clientConfirmationEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "clientChaseEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "dataFormSubmissionEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "chaseDocumentRequestFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase open document requests",
            "format": "int32",
            "nullable": true
          },
          "chaseDocumentApprovalFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase pending document approvals",
            "format": "int32",
            "nullable": true
          },
          "chaseClientConfirmationFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase pending client confirmations",
            "format": "int32",
            "nullable": true
          },
          "chaseDataFormSubmissionFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase pending data form submissions",
            "format": "int32",
            "nullable": true
          },
          "hmrcAuthorisationRequestEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "chaseHmrcAuthorisationFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase pending HMRC agent authorisation requests",
            "format": "int32",
            "nullable": true
          },
          "isChaseTextEnabled": {
            "type": "boolean",
            "description": "Whether each chase also texts each recipient who is one of the client's contacts with a mobile, one text per\nrecipient per client per chase; it texts only while the practice's messaging is Active"
          },
          "documentNotificationEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "authCodeEntryEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "Client request and chasing settings for the tenant"
      },
      "ClientRequestTextDto": {
        "type": "object",
        "properties": {
          "contactCode": {
            "type": "string",
            "description": "The contact texted",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The contact's name",
            "nullable": true
          },
          "address": {
            "type": "string",
            "description": "The mobile texted, E.164 (as typed when it could not be read as a number)",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ClientRequestTextStatus"
          },
          "heldUntil": {
            "type": "string",
            "description": "When a held text goes (UTC); null for one not held",
            "format": "date-time",
            "nullable": true
          },
          "messageId": {
            "type": "string",
            "description": "The message's id in the Messaging Service, once it answered",
            "format": "uuid",
            "nullable": true
          },
          "error": {
            "type": "string",
            "description": "Why it was not sent, or got no answer",
            "nullable": true
          },
          "sentAt": {
            "type": "string",
            "description": "When it was sent, failed or cancelled (UTC)",
            "format": "date-time",
            "nullable": true
          },
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "smsReason": {
            "$ref": "#/components/schemas/ClientRequestTextSmsReason"
          },
          "smsReasonText": {
            "type": "string",
            "description": "The reason in words, as the task shows it (\"Not known on WhatsApp.\")",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One text a client send step sent (or is holding) with its email, to one of the client's contacts, carrying the same\nlink as their email. Read-only: written by the system."
      },
      "ClientRequestTextKind": {
        "enum": [
          "DocumentRequest",
          "DocumentApproval",
          "ClientConfirmation",
          "DataForm",
          "CisPayments",
          "Chase"
        ],
        "type": "string",
        "example": "DocumentRequest"
      },
      "ClientRequestTextSmsReason": {
        "enum": [
          "SmsOnly",
          "NotKnownOnWhatsApp",
          "WhatsAppTemplateInReview",
          "WhatsAppTemplateNotApproved",
          "WhatsAppTemplateMissing",
          "WhatsAppTemplatesUnavailable",
          "WhatsAppDoNotText",
          "WhatsAppPlaceholderEmpty",
          "WhatsAppRefused",
          "NotOnWhatsApp"
        ],
        "type": "string",
        "example": "SmsOnly"
      },
      "ClientRequestTextStatus": {
        "enum": [
          "Held",
          "Pending",
          "Sent",
          "Failed",
          "Cancelled",
          "DoNotText"
        ],
        "type": "string",
        "example": "Held"
      },
      "ClientResponsivenessReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/ClientResponsivenessSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/ClientResponsivenessRowDtoPagedResult"
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC).",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Client Responsiveness report: how fast clients answer the client-facing steps we send\nthem (confirmations, document requests, data forms, approvals) and how much chasing it takes."
      },
      "ClientResponsivenessRowDto": {
        "type": "object",
        "properties": {
          "groupKind": {
            "$ref": "#/components/schemas/ReportGroupKind"
          },
          "groupCode": {
            "type": "string",
            "description": "Entity code (client/service code, or step type name). Null for null buckets.",
            "nullable": true
          },
          "groupName": {
            "type": "string",
            "description": "Display name for the group.",
            "nullable": true
          },
          "stepCount": {
            "type": "integer",
            "description": "Client-facing steps completed in the window for this group.",
            "format": "int32"
          },
          "avgResponseDays": {
            "type": "number",
            "description": "Average days from sent to completed. Null when no step carries a start timestamp.",
            "format": "double",
            "nullable": true
          },
          "medianResponseDays": {
            "type": "number",
            "description": "Median days from sent to completed.",
            "format": "double",
            "nullable": true
          },
          "totalChases": {
            "type": "integer",
            "description": "Total chase messages sent for this group's steps.",
            "format": "int32"
          },
          "chasedPct": {
            "type": "number",
            "description": "Percentage of this group's steps that needed at least one chase.",
            "format": "double"
          },
          "worstCaseDays": {
            "type": "number",
            "description": "Slowest response in days for this group.",
            "format": "double",
            "nullable": true
          },
          "worstTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "One row of the Client Responsiveness breakdown table."
      },
      "ClientResponsivenessRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientResponsivenessRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientResponsivenessSummaryDto": {
        "type": "object",
        "properties": {
          "stepCount": {
            "type": "integer",
            "description": "Client-facing steps completed in the window.",
            "format": "int32"
          },
          "avgResponseDays": {
            "type": "number",
            "description": "Average days from a step being sent to the client completing it. Null when no\ncompleted step carries a start timestamp.",
            "format": "double",
            "nullable": true
          },
          "medianResponseDays": {
            "type": "number",
            "description": "Median days from sent to completed.",
            "format": "double",
            "nullable": true
          },
          "totalChases": {
            "type": "integer",
            "description": "Total chase messages sent for the cohort's steps.",
            "format": "int32"
          },
          "chasedPct": {
            "type": "number",
            "description": "Percentage of cohort steps that needed at least one chase.",
            "format": "double"
          },
          "outstandingCount": {
            "type": "integer",
            "description": "Client-facing steps currently waiting on a client right now.",
            "format": "int32"
          },
          "oldestOutstandingDays": {
            "type": "number",
            "description": "Age in days of the oldest currently-outstanding step. Null when none.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Headline KPIs for the Client Responsiveness report."
      },
      "ClientSendingMailbox": {
        "type": "object",
        "properties": {
          "mailboxCode": {
            "type": "string",
            "nullable": true
          },
          "canChoose": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientServiceBudgetDto": {
        "type": "object",
        "properties": {
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "standardHoursMode": {
            "$ref": "#/components/schemas/StandardHoursMode"
          },
          "hoursMode": {
            "$ref": "#/components/schemas/ClientBudgetMode"
          },
          "hoursAdjustPercent": {
            "type": "number",
            "description": "The client's hours percentage, under StandardAdjusted",
            "format": "double",
            "nullable": true
          },
          "hoursLines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetLineDto"
            },
            "description": "The hours lines: one for the total",
            "nullable": true
          },
          "standardFeeMode": {
            "$ref": "#/components/schemas/StandardFeeMode"
          },
          "feeMode": {
            "$ref": "#/components/schemas/ClientBudgetMode"
          },
          "feeAdjustPercent": {
            "type": "number",
            "description": "The client's fee percentage, under StandardAdjusted",
            "format": "double",
            "nullable": true
          },
          "feeLines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetLineDto"
            },
            "description": "The fee lines: one for the total, or one per stage. Under each client's price the total line's\nStandardFigure is this client's price for a period",
            "nullable": true
          },
          "stepEstimateMinutes": {
            "type": "integer",
            "description": "The current period's step estimates, created and projected tasks alike, in minutes",
            "format": "int32"
          },
          "taskCount": {
            "type": "integer",
            "description": "Tasks in the current period, created and projected",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A client service's budget for its current period, both measures, as the Budget dialog draws it:\nhow each relates to the standard and its lines. Fee fields are null for callers without Fee\nBudgets ViewAll, and for everyone while the practice has fee budgets off."
      },
      "ClientServiceHistoryBillingFrequencyChangeDto": {
        "type": "object",
        "properties": {
          "from": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "to": {
            "$ref": "#/components/schemas/BillingFrequency"
          }
        },
        "additionalProperties": false,
        "description": "A billing period before and after a change. Null means not set."
      },
      "ClientServiceHistoryBoolChangeDto": {
        "type": "object",
        "properties": {
          "from": {
            "type": "boolean",
            "description": "The setting before the change, or null on an Added or HistoryStart entry",
            "nullable": true
          },
          "to": {
            "type": "boolean",
            "description": "The setting after the change"
          }
        },
        "additionalProperties": false,
        "description": "An on/off setting before and after a change"
      },
      "ClientServiceHistoryDateChangeDto": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "description": "The date before the change",
            "format": "date",
            "nullable": true
          },
          "to": {
            "type": "string",
            "description": "The date after the change",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A date before and after a change. Null means none."
      },
      "ClientServiceHistoryDecimalChangeDto": {
        "type": "object",
        "properties": {
          "from": {
            "type": "number",
            "description": "The value before the change",
            "format": "double",
            "nullable": true
          },
          "to": {
            "type": "number",
            "description": "The value after the change",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An amount before and after a change. Null means not set."
      },
      "ClientServiceHistoryEntryType": {
        "enum": [
          "Added",
          "HistoryStart",
          "Changed",
          "ProposalApplied"
        ],
        "type": "string",
        "example": "Added"
      },
      "ClientServiceHistoryProposalDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The proposal's code: the engagement code for Sodium, the proposal id for Socket",
            "nullable": true
          },
          "source": {
            "$ref": "#/components/schemas/ProposalSource"
          },
          "name": {
            "type": "string",
            "description": "The proposal's name as recorded when it was applied (Socket: its number and title)",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "The proposal's date (Sodium proposals)",
            "format": "date",
            "nullable": true
          },
          "acceptedDate": {
            "type": "string",
            "description": "When it was accepted (UTC; Sodium proposals)",
            "format": "date-time",
            "nullable": true
          },
          "acceptedByName": {
            "type": "string",
            "description": "The name the client signed with, when the client accepted it themselves",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The accepted proposal a client service change came from"
      },
      "ClientServiceHistoryStatusChangeDto": {
        "type": "object",
        "properties": {
          "from": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "to": {
            "$ref": "#/components/schemas/ServiceStatus"
          }
        },
        "additionalProperties": false,
        "description": "A service status before and after a change"
      },
      "ClientServiceRefDto": {
        "required": [
          "clientCode",
          "clientServiceCode"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The client's code"
          },
          "clientServiceCode": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The client service's code"
          }
        },
        "additionalProperties": false,
        "description": "A client service named by its client's code and its own code"
      },
      "ClientServiceReference": {
        "required": [
          "clientCode",
          "code"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "minLength": 1,
            "type": "string",
            "description": "The client code"
          },
          "code": {
            "minLength": 1,
            "type": "string",
            "description": "The ClientBillableService assignment code"
          }
        },
        "additionalProperties": false,
        "description": "Identifies a specific ClientBillableService assignment by its client code and service assignment code.\nBoth are required because the assignment code is only unique within a client."
      },
      "ClientSettingsDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier for the settings",
            "nullable": true
          },
          "companiesHouse_Enabled": {
            "type": "boolean",
            "description": "Whether the practice uses Companies House at all. Off disables every Companies House feature.\nTurn off for practices outside England and Wales."
          },
          "companiesHouseSync_Enabled": {
            "type": "boolean",
            "description": "Controls whether Companies House data for the tenant's linked clients is kept up to date\nautomatically from the Companies House streaming feed. Ignored when SodiumHQ.DTOs.Client.ClientSettingsDto.CompaniesHouse_Enabled is off."
          },
          "agentAuthorisations_Enabled": {
            "type": "boolean",
            "description": "Whether the practice uses HMRC agent authorisations at all. Off hides the agent authorisations\nsection on clients, the authorisation types on services, and the HMRC Agent settings page."
          },
          "clientManager_Enabled": {
            "type": "boolean",
            "description": "Whether the client manager field is enabled for clients"
          },
          "clientManager_Label": {
            "type": "string",
            "description": "Optional custom label for the client manager field. Null means use the default.",
            "nullable": true
          },
          "clientManager_Required": {
            "type": "boolean",
            "description": "Whether a client must have a client manager. Enforced on create and update only; existing clients are not backfilled.\nIgnored while ClientManager_Enabled is off."
          },
          "partner_Enabled": {
            "type": "boolean",
            "description": "Whether the partner field is enabled for clients"
          },
          "partner_Label": {
            "type": "string",
            "description": "Optional custom label for the partner field. Null means use the default.",
            "nullable": true
          },
          "partner_Required": {
            "type": "boolean",
            "description": "Whether a client must have a partner. Enforced on create and update only; existing clients are not backfilled.\nIgnored while Partner_Enabled is off."
          },
          "associate_Enabled": {
            "type": "boolean",
            "description": "Whether the associate field is enabled for clients"
          },
          "associate_Label": {
            "type": "string",
            "description": "Optional custom label for the associate field. Null means use the default.",
            "nullable": true
          },
          "associate_Required": {
            "type": "boolean",
            "description": "Whether a client must have a associate. Enforced on create and update only; existing clients are not backfilled.\nIgnored while Associate_Enabled is off."
          },
          "internalReference_Enabled": {
            "type": "boolean",
            "description": "Whether the internal reference field is enabled for clients"
          },
          "internalReference_ForceUnique": {
            "type": "boolean",
            "description": "Whether to force internal references to be unique across all clients"
          },
          "internalReference_AutoGenerate": {
            "type": "boolean",
            "description": "Whether to auto-generate the internal reference from the client code on creation"
          },
          "externalLinks_Enabled": {
            "type": "boolean",
            "description": "Whether external links are enabled for clients"
          },
          "team_Enabled": {
            "type": "boolean",
            "description": "Whether the team field is enabled for clients"
          },
          "clientLogos_Enabled": {
            "type": "boolean",
            "description": "Whether client logos are shown. Off, no client is shown with a logo or badge anywhere."
          }
        },
        "additionalProperties": false,
        "description": "Tenant-level configuration for client field visibility and behavior"
      },
      "ClientSortField": {
        "enum": [
          "Name",
          "InternalReference",
          "KeyDate",
          "VatScheme"
        ],
        "type": "string",
        "example": "Name"
      },
      "ClientStatus": {
        "enum": [
          "Active",
          "Inactive",
          "Prospect",
          "LostProspect"
        ],
        "type": "string",
        "example": "Active"
      },
      "ClientThirdPartyMappingDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The client's unique code within the tenant",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The name of the client",
            "nullable": true
          },
          "internalReference": {
            "type": "string",
            "description": "Optional internal reference for the client",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The email address for the client, used to suggest a matching customer on the accounting platform",
            "nullable": true
          },
          "primaryContactEmail": {
            "type": "string",
            "description": "The email address of the client's primary contact, used to suggest a matching customer on the accounting platform",
            "nullable": true
          },
          "accountingCustomerCode": {
            "type": "string",
            "description": "The customer code/ID from the connected accounting platform",
            "nullable": true
          },
          "directDebitMandateId": {
            "type": "string",
            "description": "The mandate ID from the connected direct debit platform",
            "nullable": true
          },
          "amlClientId": {
            "type": "string",
            "description": "The client/account ID from the connected AML platform",
            "nullable": true
          },
          "amlClientName": {
            "type": "string",
            "description": "The display name of the client in the connected AML platform",
            "nullable": true
          },
          "storageFolderPath": {
            "type": "string",
            "description": "Display path of the client's mapped document storage folder (relative to the tenant's base folder)",
            "nullable": true
          },
          "storageFolderExternalUrl": {
            "type": "string",
            "description": "URL to open the client's mapped document storage folder in the provider's web UI",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Lightweight DTO for viewing client third-party platform mappings"
      },
      "ClientThirdPartyMappingDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientThirdPartyMappingDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ClientThirdPartyMappingSortField": {
        "enum": [
          "Name",
          "InternalReference",
          "StorageFolder"
        ],
        "type": "string",
        "example": "Name"
      },
      "ClientType": {
        "enum": [
          "PrivateLimitedCompany",
          "PublicLimitedCompany",
          "LimitedLiabilityPartnership",
          "Partnership",
          "Individual",
          "Trust",
          "Charity",
          "SoleTrader",
          "Association"
        ],
        "type": "string",
        "example": "PrivateLimitedCompany"
      },
      "ClientVatTreatment": {
        "enum": [
          "Standard",
          "OutsideScope"
        ],
        "type": "string",
        "example": "Standard"
      },
      "CodeAndNameDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CodeAndNameDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CompaniesHouseAddress": {
        "type": "object",
        "properties": {
          "address_line_1": {
            "type": "string",
            "nullable": true
          },
          "address_line_2": {
            "type": "string",
            "nullable": true
          },
          "locality": {
            "type": "string",
            "nullable": true
          },
          "premises": {
            "type": "string",
            "nullable": true
          },
          "postal_code": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "region": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CompaniesHouseDateOfBirth": {
        "type": "object",
        "properties": {
          "month": {
            "type": "integer",
            "format": "int32"
          },
          "year": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "CompaniesHouseEnrichmentPreviewDto": {
        "type": "object",
        "properties": {
          "enrichCount": {
            "type": "integer",
            "description": "Clients that would be enriched.",
            "format": "int32"
          },
          "notCompanyCount": {
            "type": "integer",
            "description": "Clients skipped because their type has no Companies House record (sole traders, individuals, trusts and the like).",
            "format": "int32"
          },
          "noCompanyNumberCount": {
            "type": "integer",
            "description": "Clients skipped because they hold no company number.",
            "format": "int32"
          },
          "alreadyWaitingCount": {
            "type": "integer",
            "description": "Clients skipped because they are already waiting to be enriched.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "What enriching a selection of clients from Companies House would do: how many would be\nenriched, and how many of the rest are left out and why."
      },
      "CompaniesHouseEnrichmentRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "maxItems": 1000,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the selected clients. Clients that cannot be enriched are skipped, not rejected."
          }
        },
        "additionalProperties": false,
        "description": "The clients a user selected to enrich from Companies House."
      },
      "CompaniesHouseNameElements": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "nullable": true
          },
          "forename": {
            "type": "string",
            "nullable": true
          },
          "middle_name": {
            "type": "string",
            "nullable": true
          },
          "surname": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CompaniesHousePsc": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "name_elements": {
            "$ref": "#/components/schemas/CompaniesHouseNameElements"
          },
          "address": {
            "$ref": "#/components/schemas/CompaniesHouseAddress"
          },
          "date_of_birth": {
            "$ref": "#/components/schemas/CompaniesHouseDateOfBirth"
          },
          "nationality": {
            "type": "string",
            "nullable": true
          },
          "country_of_residence": {
            "type": "string",
            "nullable": true
          },
          "natures_of_control": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "notified_on": {
            "type": "string",
            "nullable": true
          },
          "ceased_on": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Company": {
        "type": "object",
        "properties": {
          "companyNumber": {
            "type": "string",
            "nullable": true
          },
          "companyName": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "companyStatus": {
            "type": "string",
            "nullable": true
          },
          "dateOfCreation": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "jurisdiction": {
            "type": "string",
            "nullable": true
          },
          "registeredOfficeAddress": {
            "$ref": "#/components/schemas/CompanyAddress"
          },
          "lastFullMembersListDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "nextDue": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "nextMadeUpToDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "accountingReferenceDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "nextAccountsDue": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "nextAccountsMadeUpTo": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "nextAccountsPeriodStart": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "lastAccountsMadeUpTo": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "hasCharges": {
            "type": "boolean"
          },
          "hasInsolvencyHistory": {
            "type": "boolean"
          },
          "isUndeliverableRegisteredOfficeAddress": {
            "type": "boolean"
          },
          "sicCodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SicCode"
            },
            "nullable": true
          },
          "canFile": {
            "type": "boolean"
          },
          "etag": {
            "type": "string",
            "nullable": true
          },
          "hasBeenLiquidated": {
            "type": "boolean"
          },
          "lastAccountsMadeUpToActual": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "lastAccountsType": {
            "type": "string",
            "nullable": true
          },
          "confirmationStatementLastMadeUpTo": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "accountsOverdue": {
            "type": "boolean"
          },
          "confirmationStatementOverdue": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CompanyAddress": {
        "type": "object",
        "properties": {
          "addressLine1": {
            "type": "string",
            "nullable": true
          },
          "addressLine2": {
            "type": "string",
            "nullable": true
          },
          "locality": {
            "type": "string",
            "nullable": true
          },
          "premises": {
            "type": "string",
            "nullable": true
          },
          "postalCode": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "region": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CompanyDetailsDto": {
        "type": "object",
        "properties": {
          "number": {
            "maxLength": 50,
            "type": "string",
            "description": "UK Companies House registration number",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/CompanyStatus"
          },
          "incorporationDate": {
            "type": "string",
            "description": "Date the company was incorporated/registered with Companies House",
            "format": "date-time",
            "nullable": true
          },
          "registeredAddress": {
            "maxLength": 500,
            "type": "string",
            "description": "Official registered office address as filed with Companies House",
            "nullable": true
          },
          "sicCodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Standard Industrial Classification codes describing the company's business activities",
            "nullable": true
          },
          "authenticationCode": {
            "maxLength": 100,
            "type": "string",
            "description": "Authentication code required for filing with Companies House",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Company registration and filing details (Companies House)"
      },
      "CompanySearchResponse": {
        "type": "object",
        "properties": {
          "totalResults": {
            "type": "integer",
            "format": "int32"
          },
          "itemsPerPage": {
            "type": "integer",
            "format": "int32"
          },
          "startIndex": {
            "type": "integer",
            "format": "int32"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompanySearchResult"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CompanySearchResult": {
        "type": "object",
        "properties": {
          "companyNumber": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "companyStatus": {
            "type": "string",
            "nullable": true
          },
          "companyType": {
            "type": "string",
            "nullable": true
          },
          "dateOfCreation": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "address": {
            "$ref": "#/components/schemas/CompanyAddress"
          },
          "matchedPreviousCompanyNames": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CompanyStatus": {
        "enum": [
          "Active",
          "Dissolved",
          "Dormant",
          "ProposalToStrikeOff",
          "Liquidation",
          "VoluntaryArrangement",
          "Administration",
          "ConvertedClosed",
          "Receivership",
          "InsolvencyProceedings",
          "Open",
          "Closed"
        ],
        "type": "string",
        "example": "Active"
      },
      "CompleteCisPaymentsRequest": {
        "type": "object",
        "properties": {
          "noPayments": {
            "type": "boolean",
            "description": "The contractor paid no subcontractors in the month. Refused when CIS Manager has payments for the month"
          }
        },
        "additionalProperties": false,
        "description": "The team completes a Collect CIS payments step collected by staff, once the month's payments are in CIS Manager\n(or there were none)."
      },
      "CompleteMandateSetupRequest": {
        "required": [
          "redirectFlowId"
        ],
        "type": "object",
        "properties": {
          "redirectFlowId": {
            "minLength": 1,
            "type": "string",
            "description": "The redirect flow ID returned by GoCardless in the callback URL query string."
          }
        },
        "additionalProperties": false,
        "description": "Request model for completing a GoCardless Direct Debit mandate setup\nafter the user has authorised the mandate."
      },
      "ComposedEmail": {
        "required": [
          "htmlBody",
          "subject"
        ],
        "type": "object",
        "properties": {
          "subject": {
            "maxLength": 1000,
            "minLength": 1,
            "type": "string",
            "description": "The subject line."
          },
          "htmlBody": {
            "minLength": 1,
            "type": "string",
            "description": "The body as HTML, from the preview. Must keep the preview's link placeholder, which is swapped\nfor each recipient's own link when the email goes out."
          },
          "configCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The connection to send from. Omit to use the step's sender or the practice's client email sender rule.",
            "nullable": true
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "CC recipients, on the first recipient's email only.",
            "nullable": true
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "BCC recipients, on the first recipient's email only.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An email as the user edited it in the composer, from a preview. Sent in place of the practice's\ntemplate, with each To recipient getting their own link in place of the preview's placeholder.\nUsed for approval requests, and for sending an information request and telling a client about items added to it."
      },
      "ConditionComparison": {
        "enum": [
          "Equals",
          "IsNotEmpty",
          "IsEmpty"
        ],
        "type": "string",
        "example": "Equals"
      },
      "ConditionDto": {
        "type": "object",
        "properties": {
          "sourceType": {
            "$ref": "#/components/schemas/ConditionSourceType"
          },
          "questionCode": {
            "type": "string",
            "description": "When SourceType is FormQuestion: the code of the question whose answer is compared.\nOnly valid on data form sections/questions.",
            "nullable": true
          },
          "clientField": {
            "$ref": "#/components/schemas/ClientCsvTargetField"
          },
          "customFieldDefinition": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "comparison": {
            "$ref": "#/components/schemas/ConditionComparison"
          },
          "showWhenIs": {
            "type": "string",
            "description": "For an Equals condition, the value the condition source must have for the item to be\nvisible/included: \"true\" or \"false\" for booleans, the option value for dropdowns. Ignored\n(and stored as null) for IsNotEmpty and IsEmpty.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A conditional-visibility rule shared by data form sections/questions, workflow groups/steps and\ncustom field groups: the item is only shown/included when the referenced field passes the\ncomparison (equal to ShowWhenIs, filled in, or empty). Null (no condition object) means the item\nis always shown."
      },
      "ConditionSourceType": {
        "enum": [
          "FormQuestion",
          "ClientField",
          "CustomField"
        ],
        "type": "string",
        "example": "FormQuestion"
      },
      "ConfigurationStatus": {
        "enum": [
          "PendingOAuthSetup",
          "Active",
          "OAuthFailed",
          "Deleted",
          "OAuthExpired",
          "ConnectionError",
          "Deleting"
        ],
        "type": "string",
        "description": "Represents the lifecycle status of an email configuration",
        "example": "PendingOAuthSetup"
      },
      "ConfirmCsvImportRequest": {
        "type": "object",
        "properties": {
          "mappingCode": {
            "type": "string",
            "description": "Code of an existing saved mapping to use for this import.\nUse GET /mappings to list available mappings (includes system defaults like 'limited-company-clients').\nMutually exclusive with ColumnMappings - provide one or the other, not both.\nIf neither is provided, the suggested mappings from the preview will be used.",
            "nullable": true,
            "example": "limited-company-clients"
          },
          "columnMappings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CsvColumnMappingDto"
            },
            "description": "Inline column mappings to use for this import.\nEach mapping specifies which CSV header maps to which target field.\nMutually exclusive with MappingCode - provide one or the other, not both.\nIf neither is provided, the suggested mappings from the preview will be used.",
            "nullable": true
          },
          "matchField": {
            "$ref": "#/components/schemas/CsvImportMatchField"
          },
          "importMode": {
            "$ref": "#/components/schemas/CsvImportMode"
          },
          "enrichFromCompaniesHouse": {
            "type": "boolean",
            "description": "Whether to enrich created and updated clients with Companies House data after import.\nOnly applies to eligible company types (excludes Individual, SoleTrader, Trust, Association).\nDefault: false",
            "example": true
          },
          "defaultClientType": {
            "$ref": "#/components/schemas/ClientType"
          }
        },
        "additionalProperties": false,
        "description": "Request to confirm column mapping configuration and start a CSV import job.\nUsed after uploading a CSV with showPreview=true to finalize the mapping and begin import."
      },
      "ConnectHmrcRequest": {
        "type": "object",
        "properties": {
          "returnTo": {
            "type": "string",
            "description": "Optional relative path (must start with /) the user should be returned to after completing\nthe HMRC consent journey — e.g. the page the connect journey started from.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to start the HMRC consent journey."
      },
      "ConnectMessagingWhatsAppRequest": {
        "required": [
          "displayName",
          "wabaId"
        ],
        "type": "object",
        "properties": {
          "address": {
            "maxLength": 30,
            "minLength": 0,
            "type": "string",
            "description": "A number the practice already has, the one it gave in Meta's popup; null connects the practice's own SMS number",
            "nullable": true
          },
          "wabaId": {
            "maxLength": 50,
            "minLength": 0,
            "pattern": "^[0-9]+$",
            "type": "string",
            "description": "The WhatsApp Business Account Embedded Signup created (its FINISH event's waba_id)"
          },
          "displayName": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The display name WhatsApp shows, which Meta reviews (Meta's display name rules apply)"
          }
        },
        "additionalProperties": false,
        "description": "Connects the practice's own number to WhatsApp once Meta's Embedded Signup has finished"
      },
      "ConnectionCredentialsResponse": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string",
            "description": "The OAuth access token",
            "nullable": true
          },
          "clientId": {
            "type": "string",
            "description": "The OAuth client ID",
            "nullable": true
          },
          "baseUrl": {
            "type": "string",
            "description": "The SharePoint/OneDrive base URL for the file picker",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response containing OAuth credentials for a connection"
      },
      "ConnectionFolderDto": {
        "type": "object",
        "properties": {
          "containerId": {
            "type": "string",
            "description": "Platform-specific folder identifier. Pass this back as `parentFolderId` to drill in.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Folder display name.",
            "nullable": true
          },
          "webUrl": {
            "type": "string",
            "description": "Direct link to open the folder in the provider's web UI.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A folder available in a document storage connection. Returned by the list-folders endpoint\nused to drive the in-app folder browser."
      },
      "ConnectionOptionsDto": {
        "type": "object",
        "properties": {
          "importMeetingTranscripts": {
            "type": "boolean",
            "description": "Meeting notes connections: whether each meeting's full transcript is brought in as well as its notes. Only affects\nmeetings imported from then on. Off unless asked for.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a practice can choose about one connection. An option the connection's platform does not offer is null."
      },
      "ConnectionStatus": {
        "enum": [
          "NotInitiated",
          "Initialising",
          "Active",
          "Expired",
          "Revoked",
          "Error"
        ],
        "type": "string",
        "example": "NotInitiated"
      },
      "ContactClientLinkDto": {
        "type": "object",
        "properties": {
          "client": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "clientType": {
            "$ref": "#/components/schemas/ClientType"
          },
          "role": {
            "type": "string",
            "description": "The contact's role on the client, e.g. Director",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "How the contact relates to the client, e.g. Main",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client a contact is linked to, with the contact's role on it."
      },
      "ContactClientLinks": {
        "enum": [
          "AnyClient",
          "Unassigned",
          "Multiple"
        ],
        "type": "string",
        "example": "AnyClient"
      },
      "ContactCsvExportFilterDto": {
        "type": "object",
        "properties": {
          "clientLinks": {
            "$ref": "#/components/schemas/ContactClientLinks"
          },
          "hasEmail": {
            "type": "boolean",
            "description": "True for contacts with a main email address, false for contacts without one.",
            "nullable": true
          },
          "isFromCompaniesHouse": {
            "type": "boolean",
            "description": "True for contacts imported from Companies House officers, false for all others.",
            "nullable": true
          },
          "hasPortalAccess": {
            "type": "boolean",
            "description": "True for contacts with active client portal access, false for contacts without.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Filters for selecting which contacts to export."
      },
      "ContactCsvExportRequestDto": {
        "type": "object",
        "properties": {
          "includeHeaders": {
            "type": "boolean",
            "description": "Whether to include a header row in the CSV output. Default: true"
          },
          "filter": {
            "$ref": "#/components/schemas/ContactCsvExportFilterDto"
          }
        },
        "additionalProperties": false,
        "description": "Request to start a CSV export of contacts. Without filters every contact is exported."
      },
      "ContactDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this contact",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "The contact's title (e.g., Mr, Mrs, Dr)",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "description": "The contact's first name",
            "nullable": true
          },
          "middleName": {
            "type": "string",
            "description": "The contact's middle name",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "description": "The contact's last name",
            "nullable": true
          },
          "preferredName": {
            "type": "string",
            "description": "The name the contact goes by, when different from their first name (e.g. Matt for Matthias)",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The contact's email address",
            "nullable": true
          },
          "alternativeEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional email addresses the contact also uses. Email remains the primary\naddress and is the default for outgoing communication.",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "description": "The contact's phone number",
            "nullable": true
          },
          "mobile": {
            "type": "string",
            "description": "The contact's mobile number",
            "nullable": true
          },
          "isMobileOnWhatsApp": {
            "type": "boolean",
            "description": "The mobile is known on WhatsApp to this practice (it has messaged the practice on WhatsApp, or a WhatsApp\nmessage to it was delivered or read): the web shows the WhatsApp icon beside it. Read only."
          },
          "alternativePhoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional phone numbers the contact also uses. Phone and Mobile remain the\nprimary numbers.",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "description": "The contact's date of birth",
            "format": "date",
            "nullable": true
          },
          "utr": {
            "type": "string",
            "description": "The contact's Unique Taxpayer Reference (Self Assessment UTR).\nUsed for individuals' personal tax affairs.",
            "nullable": true
          },
          "niNumber": {
            "type": "string",
            "description": "The contact's National Insurance Number.",
            "nullable": true
          },
          "cgtReference": {
            "type": "string",
            "description": "The contact's Capital Gains Tax on UK property account number, issued by HMRC when they\nfirst report a property disposal.",
            "nullable": true
          },
          "personalCode": {
            "type": "string",
            "description": "The contact's Companies House person ID code, used to uniquely identify\nan individual within the Companies House system.",
            "nullable": true
          },
          "companiesHouseOfficerId": {
            "type": "string",
            "description": "Companies House's own identifier for this person, taken from the officer register when the\ncontact was imported from Companies House. Set by the import, not by hand: it is what lets\nthe same director be recognised on another client's company with certainty.",
            "nullable": true
          },
          "companiesHouseDateOfBirth": {
            "type": "string",
            "description": "The month and year of birth Companies House publishes for this person, with the day set to\n1. Used to tell two people of the same name apart. Set by the Companies House import.",
            "format": "date",
            "nullable": true
          },
          "address": {
            "type": "string",
            "description": "The contact's address. Only used when the client type is Individual.",
            "nullable": true
          },
          "nationality": {
            "$ref": "#/components/schemas/Nationality"
          },
          "maritalStatus": {
            "$ref": "#/components/schemas/MaritalStatus"
          },
          "isDeceased": {
            "type": "boolean",
            "description": "Whether this contact is deceased"
          },
          "deceasedDate": {
            "type": "string",
            "description": "The date the contact was deceased, if known",
            "format": "date",
            "nullable": true
          },
          "clientCount": {
            "type": "integer",
            "description": "The number of clients this contact is associated with.",
            "format": "int32"
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "portalUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "individualClient": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "duplicateGroup": {
            "type": "string",
            "description": "Key shared by the contacts that are likely the same person. Only returned when hasDuplicates=true.",
            "nullable": true
          },
          "duplicateConfidence": {
            "$ref": "#/components/schemas/ContactMatchConfidence"
          },
          "duplicateReasons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactDuplicateReason"
            },
            "description": "Why the group's contacts are likely the same person. Only returned when hasDuplicates=true.",
            "nullable": true
          },
          "duplicateMergeStatus": {
            "$ref": "#/components/schemas/ContactMergeStatus"
          },
          "duplicates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactDto"
            },
            "description": "The contacts that are likely the same person as this one. Only returned on a single contact\nwhen hasDuplicates=true; empty when there are none.",
            "nullable": true
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactClientLinkDto"
            },
            "description": "Every client this contact is linked to. Only returned when hasDuplicates=true.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents a person or contact within the tenant's organization.\nContacts can be associated with one or more clients and contain contact details such as name, email, and phone numbers."
      },
      "ContactDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ContactDuplicateReason": {
        "enum": [
          "CompaniesHouseOfficer",
          "NiNumber",
          "Utr",
          "NameAndDateOfBirth",
          "NameAndEmail",
          "NameOnly"
        ],
        "type": "string",
        "example": "CompaniesHouseOfficer"
      },
      "ContactMatchConfidence": {
        "enum": [
          "Possible",
          "Strong",
          "Certain"
        ],
        "type": "string",
        "example": "Possible"
      },
      "ContactMatchDto": {
        "type": "object",
        "properties": {
          "confidence": {
            "$ref": "#/components/schemas/ContactMatchConfidence"
          },
          "contact": {
            "$ref": "#/components/schemas/ContactDto"
          }
        },
        "additionalProperties": false,
        "description": "One existing contact that might be the same person, and how sure we are."
      },
      "ContactMatchResultDto": {
        "type": "object",
        "properties": {
          "reference": {
            "type": "string",
            "description": "The reference the caller sent this person under.",
            "nullable": true
          },
          "matches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactMatchDto"
            },
            "description": "Contacts that could be this person, most likely first. Empty when the practice does not\nhold them. Contacts that positively contradict the person - a different Companies House\nofficer id, a different month of birth - are not listed at all.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The existing contacts that might be one person from a match request."
      },
      "ContactMergeBlocker": {
        "enum": [
          "MultiplePortalLogins",
          "MultipleIndividualClients"
        ],
        "type": "string",
        "example": "MultiplePortalLogins"
      },
      "ContactMergeBlockerDto": {
        "type": "object",
        "properties": {
          "code": {
            "$ref": "#/components/schemas/ContactMergeBlocker"
          },
          "contactCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The contacts involved.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A reason the contacts cannot be merged."
      },
      "ContactMergeClientDto": {
        "type": "object",
        "properties": {
          "client": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "outcome": {
            "$ref": "#/components/schemas/ContactMergeClientOutcome"
          },
          "fromContactCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The contacts linked to the client before the merge.",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "How the kept contact relates to the client after the merge.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What happens to a client the contacts are linked to."
      },
      "ContactMergeClientOutcome": {
        "enum": [
          "Unchanged",
          "Moved",
          "Combined"
        ],
        "type": "string",
        "example": "Unchanged"
      },
      "ContactMergeContactDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The contact's code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "First and last name.",
            "nullable": true
          },
          "hasPortalAccess": {
            "type": "boolean",
            "description": "Whether the contact has an active portal login."
          },
          "isCompaniesHouseOfficer": {
            "type": "boolean",
            "description": "Whether the contact is linked to a Companies House officer."
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactClientLinkDto"
            },
            "description": "The clients the contact is linked to.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A contact taking part in a merge."
      },
      "ContactMergeField": {
        "enum": [
          "Title",
          "FirstName",
          "MiddleName",
          "LastName",
          "PreferredName",
          "Email",
          "Phone",
          "Mobile",
          "DateOfBirth",
          "Utr",
          "NiNumber",
          "PersonalCode",
          "Address",
          "Nationality",
          "MaritalStatus",
          "CgtReference"
        ],
        "type": "string",
        "example": "Title"
      },
      "ContactMergeFieldDto": {
        "type": "object",
        "properties": {
          "field": {
            "$ref": "#/components/schemas/ContactMergeField"
          },
          "keptContactCode": {
            "type": "string",
            "description": "The contact whose value is kept by default: the kept contact's, else the first contact with a value. Null when none has one.",
            "nullable": true
          },
          "hasConflict": {
            "type": "boolean",
            "description": "Whether the contacts hold different values."
          },
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactMergeFieldValueDto"
            },
            "description": "Each contact's value, in the same order as the contacts.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single-value field across the contacts."
      },
      "ContactMergeFieldValueDto": {
        "type": "object",
        "properties": {
          "contactCode": {
            "type": "string",
            "description": "The contact.",
            "nullable": true
          },
          "value": {
            "type": "string",
            "description": "The value, null when the contact has none. Dates are yyyy-MM-dd.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One contact's value for a field."
      },
      "ContactMergePortalAccessDto": {
        "type": "object",
        "properties": {
          "outcome": {
            "$ref": "#/components/schemas/ContactMergePortalOutcome"
          },
          "contactCode": {
            "type": "string",
            "description": "The contact that holds the login before the merge. Null when none does.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What happens to the active portal login."
      },
      "ContactMergePortalOutcome": {
        "enum": [
          "None",
          "Unchanged",
          "Moved"
        ],
        "type": "string",
        "example": "None"
      },
      "ContactMergePreviewDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The contact that is kept.",
            "nullable": true
          },
          "suggestedCode": {
            "type": "string",
            "description": "The contact best kept: an active portal login, then an individual client, then most clients, then most details, then oldest.",
            "nullable": true
          },
          "contacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactMergeContactDto"
            },
            "description": "The kept contact first, then the merged contacts in the order given.",
            "nullable": true
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactMergeFieldDto"
            },
            "description": "Each single-value field across the contacts.",
            "nullable": true
          },
          "emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactMergeSharedValueDto"
            },
            "description": "Every unique email address across the contacts, compared ignoring case.",
            "nullable": true
          },
          "phoneNumbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactMergeSharedValueDto"
            },
            "description": "Every unique phone number across the contacts, compared ignoring spaces and symbols, with + and 00 treated alike.",
            "nullable": true
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactMergeClientDto"
            },
            "description": "What happens to each client the contacts are linked to.",
            "nullable": true
          },
          "portalAccess": {
            "$ref": "#/components/schemas/ContactMergePortalAccessDto"
          },
          "deletedContactCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The contacts deleted by the merge.",
            "nullable": true
          },
          "result": {
            "$ref": "#/components/schemas/UpdateContactRequest"
          },
          "blockers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactMergeBlockerDto"
            },
            "description": "Why the contacts cannot be merged. Empty when they can.",
            "nullable": true
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactMergeWarningDto"
            },
            "description": "Things worth checking before merging. The merge is still allowed.",
            "nullable": true
          },
          "mergeStatus": {
            "$ref": "#/components/schemas/ContactMergeStatus"
          }
        },
        "additionalProperties": false,
        "description": "What merging contacts into a kept contact would produce. Nothing is changed."
      },
      "ContactMergeSharedValueDto": {
        "type": "object",
        "properties": {
          "value": {
            "type": "string",
            "description": "The email address or phone number.",
            "nullable": true
          },
          "contactCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The contacts that hold it.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An email address or phone number and the contacts that hold it."
      },
      "ContactMergeStatus": {
        "enum": [
          "Ready",
          "DetailsToChoose",
          "CheckSamePerson",
          "Blocked"
        ],
        "type": "string",
        "example": "Ready"
      },
      "ContactMergeWarning": {
        "enum": [
          "DifferentDateOfBirth",
          "DifferentNiNumber",
          "DifferentUtr",
          "MultipleAmlContactIds"
        ],
        "type": "string",
        "example": "DifferentDateOfBirth"
      },
      "ContactMergeWarningDto": {
        "type": "object",
        "properties": {
          "code": {
            "$ref": "#/components/schemas/ContactMergeWarning"
          },
          "field": {
            "$ref": "#/components/schemas/ContactMergeField"
          },
          "clientCode": {
            "type": "string",
            "description": "The client it concerns, if any.",
            "nullable": true
          },
          "contactCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The contacts involved.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Something worth checking before merging."
      },
      "ContactPreferencesDto": {
        "type": "object",
        "properties": {
          "post": {
            "type": "boolean",
            "description": "Whether the client can be contacted by post"
          },
          "telephone": {
            "type": "boolean",
            "description": "Whether the client can be contacted by telephone"
          },
          "email": {
            "type": "boolean",
            "description": "Whether the client can be contacted by email"
          },
          "sms": {
            "type": "boolean",
            "description": "Whether the client can be contacted by SMS"
          },
          "whatsApp": {
            "type": "boolean",
            "description": "Whether the client can be contacted by WhatsApp"
          }
        },
        "additionalProperties": false,
        "description": "Contact preferences for a client"
      },
      "ContactSortField": {
        "enum": [
          "Name",
          "FirstName",
          "LastName",
          "ClientCount",
          "PreferredName"
        ],
        "type": "string",
        "example": "Name"
      },
      "ContentBlockCategory": {
        "enum": [
          "Custom",
          "ServiceTerms",
          "ServiceProposals",
          "TemplateParts",
          "WebContent",
          "Email",
          "EmailParts",
          "AdHocEmails"
        ],
        "type": "string",
        "example": "Custom"
      },
      "ContentBlockCollection": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContentBlockReference"
            },
            "description": "List of content block references with their variables.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Collection of content block references.\nGeneric wrapper that can be reused for any list of content blocks (schedules, sections, etc.)."
      },
      "ContentBlockDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "bodyHtml": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "$ref": "#/components/schemas/ContentBlockCategory"
          },
          "subjectLine": {
            "type": "string",
            "description": "Optional subject line for email content blocks (only relevant when Category is EmailParts).\nSupports merge field syntax (e.g., {{ Client.Name }}).",
            "nullable": true
          },
          "hasClientTokens": {
            "type": "boolean",
            "description": "Whether any field (SubjectLine or BodyHtml) contains {{ Client.* }} Liquid tokens.\nUse to determine if a content block requires a client context for rendering."
          },
          "createdDate": {
            "type": "string",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for content blocks, exposing only codes and structured data (never DB IDs)."
      },
      "ContentBlockDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContentBlockDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ContentBlockEmailTokensDto": {
        "type": "object",
        "properties": {
          "requiresClient": {
            "type": "boolean",
            "description": "Whether any token is about a client, so the email cannot be completed without choosing one."
          },
          "usesRecipientTokens": {
            "type": "boolean",
            "description": "Whether any {{ Contact }} token is used. These are completed from the first To address that belongs to one of the\nclient's contacts."
          },
          "unavailableTokens": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Tokens a one-off email has nothing to complete from (task dates, custom tokens), which render blank.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a content block's tokens need before it can start a one-off email, including any blocks it includes."
      },
      "ContentBlockReference": {
        "type": "object",
        "properties": {
          "contentBlock": {
            "type": "string",
            "description": "The code of the content block to render.",
            "nullable": true
          },
          "vars": {
            "type": "object",
            "additionalProperties": { },
            "description": "Variables to pass to the content block template.\nThese become available in the content block's template context.\nExample: { \"price\": 1000, \"billingFrequency\": \"Monthly\" }",
            "nullable": true
          },
          "meta": {
            "description": "Optional metadata for additional context (not passed to template).\nCan be used for conditional logic or tracking purposes."
          }
        },
        "additionalProperties": false,
        "description": "Generic container for passing dynamic content blocks with variables and metadata to templates.\nThis allows templates to render content blocks with additional context (e.g., price, frequency)."
      },
      "ContentBlockSortField": {
        "enum": [
          "Name",
          "Category",
          "UpdatedDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "ConversationClientAssociationDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client associated with a conversation"
      },
      "ConversationClientSuggestionDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name",
            "nullable": true
          },
          "matchedEmail": {
            "type": "string",
            "description": "The email address that matched (from a contact or the client itself)",
            "nullable": true
          },
          "matchedVia": {
            "type": "string",
            "description": "Where the match was found: \"client\" (the client's own email) or the contact's name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A suggested client to associate with a conversation, based on matching participant emails"
      },
      "ConversationCommentDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this comment",
            "nullable": true
          },
          "text": {
            "type": "string",
            "description": "The comment text",
            "nullable": true
          },
          "author": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When the comment was written",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the comment was last edited",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An internal comment on an email conversation. Mentions are written into the text as\n`@[Name](user-code)`."
      },
      "ConversationLinkDto": {
        "type": "object",
        "properties": {
          "conversationLinkKey": {
            "type": "string",
            "description": "The caller's identifier for what the conversation is filed against.",
            "nullable": true
          },
          "isExclusion": {
            "type": "boolean",
            "description": "False when the conversation is filed against the key; true when it is kept off the key."
          }
        },
        "additionalProperties": false,
        "description": "A conversation filed against a caller's key, or kept off it."
      },
      "ConversationRef": {
        "required": [
          "configCode",
          "conversationId"
        ],
        "type": "object",
        "properties": {
          "configCode": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The mailbox's email config code"
          },
          "conversationId": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "The provider's thread id"
          }
        },
        "additionalProperties": false,
        "description": "One conversation of a mailbox"
      },
      "ConversationSummaryDto": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "The summary, plain text",
            "nullable": true
          },
          "source": {
            "$ref": "#/components/schemas/ConversationSummarySource"
          },
          "updatedBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "The summary of an email conversation, written by hand or by the AI\n(docs/features/ConversationSummary/PLAN.md D2)"
      },
      "ConversationSummarySource": {
        "enum": [
          "Manual",
          "Ai"
        ],
        "type": "string",
        "example": "Manual"
      },
      "ConversationTriageCountsDto": {
        "type": "object",
        "properties": {
          "matched": {
            "type": "integer",
            "description": "Open conversations in the Matched view",
            "format": "int32"
          },
          "unmatched": {
            "type": "integer",
            "description": "Open conversations in the Unmatched view",
            "format": "int32"
          },
          "other": {
            "type": "integer",
            "description": "Open conversations in the Other view",
            "format": "int32"
          },
          "assignedToMe": {
            "type": "integer",
            "description": "Open conversations assigned to the caller, in any view",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Open conversations per triage view, across the caller's mailboxes that have triage on\n(docs/features/EmailTriage/PLAN.md D17). Open means not at a Done status."
      },
      "ConversationTriageDto": {
        "type": "object",
        "properties": {
          "conversationId": {
            "type": "string",
            "description": "The conversation (provider thread id)",
            "nullable": true
          },
          "statusCode": {
            "type": "string",
            "description": "The conversation's effective status, by the list's rule: its own, else the first active Done status\nwhen it predates triage being switched on, else the mailbox's default status",
            "nullable": true
          },
          "assigneeCode": {
            "type": "string",
            "description": "Who the conversation is assigned to; null when unassigned",
            "nullable": true
          },
          "assignedByCode": {
            "type": "string",
            "description": "Who made the assignment; null when the mailbox's defaults did",
            "nullable": true
          },
          "notifyAssignerOnDone": {
            "type": "boolean",
            "description": "Whether the assigner wants to hear when the conversation is done"
          },
          "statusChangedAt": {
            "type": "string",
            "description": "When the status was last set (UTC); null when it never has been",
            "format": "date-time",
            "nullable": true
          },
          "isMatched": {
            "type": "boolean",
            "description": "Whether a client is involved: true Matched, false Other (everyone involved is known not to be a\nclient), null Unmatched (not known yet)",
            "nullable": true
          },
          "commentCount": {
            "type": "integer",
            "description": "How many internal comments the conversation has",
            "format": "int32"
          },
          "bringBackAt": {
            "type": "string",
            "description": "When the conversation is brought back to SodiumHQ.DTOs.EmailTriage.ConversationTriageDto.BringBackStatusCode (UTC), if its status has not changed by\nthen; null when no bring back is pending",
            "format": "date-time",
            "nullable": true
          },
          "bringBackStatusCode": {
            "type": "string",
            "description": "The status the pending bring back moves the conversation to",
            "nullable": true
          },
          "summary": {
            "$ref": "#/components/schemas/ConversationSummaryDto"
          }
        },
        "additionalProperties": false,
        "description": "A conversation's triage state as the email page shows it (docs/features/EmailTriage/PLAN.md D13)"
      },
      "ConversationWithAssociationsDto": {
        "type": "object",
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalMailboxEmailSummaryDto"
            },
            "description": "The messages in this conversation, ordered by date",
            "nullable": true
          },
          "clientAssociations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConversationClientAssociationDto"
            },
            "description": "Clients associated with this conversation based on participant email addresses matching client email rules.\nEmpty if no participants match any rules.",
            "nullable": true
          },
          "suggestedClients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConversationClientSuggestionDto"
            },
            "description": "Suggested clients to associate with this conversation, based on participant email addresses\nmatching client or contact email addresses. Only populated when there are no existing associations.",
            "nullable": true
          },
          "participantEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The unique participant email addresses from this conversation's messages.\nUseful for creating association rules from the frontend.",
            "nullable": true
          },
          "taskAssociations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Tasks explicitly linked to this conversation by users.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A conversation's messages enriched with client associations derived from email rules."
      },
      "ConvertFieldWarningType": {
        "enum": [
          "UnsupportedClientField",
          "UnknownCustomField"
        ],
        "type": "string",
        "description": "Types of conversion warnings",
        "example": "UnsupportedClientField"
      },
      "ConvertFormFieldWarning": {
        "type": "object",
        "properties": {
          "formName": {
            "type": "string",
            "description": "The name of the form containing the unmapped field",
            "nullable": true
          },
          "sectionTitle": {
            "type": "string",
            "description": "The section title containing the unmapped field",
            "nullable": true
          },
          "questionLabel": {
            "type": "string",
            "description": "The question label/prompt",
            "nullable": true
          },
          "originalField": {
            "type": "string",
            "description": "The original field identifier from the source system",
            "nullable": true
          },
          "warningType": {
            "$ref": "#/components/schemas/ConvertFieldWarningType"
          }
        },
        "additionalProperties": false,
        "description": "A warning about a field that could not be automatically mapped during conversion"
      },
      "ConvertFormFileRequest": {
        "type": "object",
        "properties": {
          "content": {
            "type": "string",
            "description": "The raw file content (e.g. a CEXP-V1 export file)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to convert an external form definition file into the Sodium import format.\nThe raw file content is posted as the request body (text/plain)."
      },
      "ConvertFormFileResponse": {
        "type": "object",
        "properties": {
          "forms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreateDataFormRequest"
            },
            "description": "The converted forms in Sodium's CreateDataFormRequest format, ready for import",
            "nullable": true
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConvertFormFieldWarning"
            },
            "description": "Warnings about fields that could not be automatically mapped (e.g. unrecognised custom fields, unsupported builtin fields)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Result of converting an external form definition file into the Sodium import format"
      },
      "CostProfitReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/CostProfitSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/CostProfitRowDtoPagedResult"
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Cost & Profit report: what tracked time cost the practice over a period, what the\nbillable portion of it was worth, and the profit between the two — grouped by team member\nor client. Cost counts all time (billable or not) at the stamped cost rate; billable value\ncounts billable time at the stamped charge-out rate, whether billed yet or not."
      },
      "CostProfitRowDto": {
        "type": "object",
        "properties": {
          "groupCode": {
            "type": "string",
            "description": "The group's code — the user code or client code; null for the \"No client\" row",
            "nullable": true
          },
          "groupName": {
            "type": "string",
            "description": "The group's display name; \"No client\" for time logged without a client when\ngrouping by client",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The client, when grouped by client service (the group name is then the service)",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "nullable": true
          },
          "price": {
            "type": "number",
            "description": "When grouped by client service: the service's period amount times the periods starting in the\nwindow; null for a package-priced member or a service with no period starting in it. Fee\nBudgets holders only, while the practice has budgets and fee budgets on.",
            "format": "double",
            "nullable": true
          },
          "feeBudget": {
            "type": "number",
            "description": "When grouped by client service: the effective fee budget of the periods starting in the window;\nnull when none of them has one. Fee Budgets holders only, while the practice has budgets and fee\nbudgets on.",
            "format": "double",
            "nullable": true
          },
          "valueOfAllTime": {
            "type": "number",
            "description": "When grouped by client service: every minute logged in the window, billable or not, at the\ncharge-out rate stamped on its entry (ClientJobBudgets R4, R5): the figure the fee budget is\nmeasured against. The billable value and recovery stay billing figures. Fee Budgets holders only,\nwhile the practice has budgets and fee budgets on.",
            "format": "double",
            "nullable": true
          },
          "totalMinutes": {
            "type": "integer",
            "description": "Minutes logged in the window",
            "format": "int32"
          },
          "billableMinutes": {
            "type": "integer",
            "description": "Of those, the minutes marked billable",
            "format": "int32"
          },
          "nonBillableMinutes": {
            "type": "integer",
            "description": "Of those, the minutes not marked billable",
            "format": "int32"
          },
          "entryCount": {
            "type": "integer",
            "description": "Number of time entries behind the totals",
            "format": "int32"
          },
          "costAmount": {
            "type": "number",
            "description": "What the group's time cost the practice at the stamped cost rates",
            "format": "double"
          },
          "billableAmount": {
            "type": "number",
            "description": "What the group's billable time is worth at the stamped charge-out rates",
            "format": "double"
          },
          "profitAmount": {
            "type": "number",
            "description": "Billable value minus cost",
            "format": "double"
          },
          "settledAmount": {
            "type": "number",
            "description": "WIP the group's time has settled through billing or write-off (allocations against the\nentries in the window, whenever the disposal was recorded)",
            "format": "double"
          },
          "billedAmount": {
            "type": "number",
            "description": "What clients were charged for that time on Sodium's billing lines. Time billed before\nthe allocation model existed reads as billed at full value.",
            "format": "double"
          },
          "writtenOffAmount": {
            "type": "number",
            "description": "Settled minus billed: time written off (negative is written on)",
            "format": "double"
          },
          "recoveryRate": {
            "type": "number",
            "description": "Billed as a share of the billable value, as a percentage. Null when there is no billable\nvalue. Money billed on account with no time behind it is not counted here; see the WIP\nValue report for job-level recovery.",
            "format": "double",
            "nullable": true
          },
          "uncostedEntryCount": {
            "type": "integer",
            "description": "Entries with no cost rate stamped — minutes counted, cost not",
            "format": "int32"
          },
          "unratedEntryCount": {
            "type": "integer",
            "description": "Billable entries with no charge-out rate stamped — minutes counted, value not",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One group's row on the Cost & Profit report — a team member or a client"
      },
      "CostProfitRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CostProfitRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CostProfitSummaryDto": {
        "type": "object",
        "properties": {
          "totalMinutes": {
            "type": "integer",
            "description": "Total minutes logged in the window",
            "format": "int32"
          },
          "billableMinutes": {
            "type": "integer",
            "description": "Of those, the minutes marked billable",
            "format": "int32"
          },
          "costAmount": {
            "type": "number",
            "description": "What the logged time cost the practice: all minutes at the stamped cost rates,\nthe minutes per distinct rate valued to the penny",
            "format": "double"
          },
          "billableAmount": {
            "type": "number",
            "description": "What the billable time is worth: billable minutes at the stamped charge-out rates,\nsame rounding law — whether the time has been billed yet or not",
            "format": "double"
          },
          "profitAmount": {
            "type": "number",
            "description": "Billable value minus cost — negative when the time cost more than it can be billed for",
            "format": "double"
          },
          "settledAmount": {
            "type": "number",
            "description": "WIP the window's time has settled through billing or write-off (allocations against the\nentries in the window, whenever the disposal was recorded)",
            "format": "double"
          },
          "billedAmount": {
            "type": "number",
            "description": "What clients were charged for that time on Sodium's billing lines. Time billed before\nthe allocation model existed reads as billed at full value.",
            "format": "double"
          },
          "writtenOffAmount": {
            "type": "number",
            "description": "Settled minus billed: time written off (negative is written on)",
            "format": "double"
          },
          "recoveryRate": {
            "type": "number",
            "description": "Billed as a share of the billable value, as a percentage. Null when there is no billable\nvalue. Money billed on account with no time behind it is not counted here; see the WIP\nValue report for job-level recovery.",
            "format": "double",
            "nullable": true
          },
          "entryCount": {
            "type": "integer",
            "description": "Number of time entries in the window",
            "format": "int32"
          },
          "uncostedEntryCount": {
            "type": "integer",
            "description": "Entries with no cost rate stamped — they contribute minutes but no cost\n(typically entries created before cost rates were set)",
            "format": "int32"
          },
          "unratedEntryCount": {
            "type": "integer",
            "description": "Billable entries with no charge-out rate stamped — they contribute minutes but no\nbillable value",
            "format": "int32"
          },
          "groupCount": {
            "type": "integer",
            "description": "Number of rows (groups) in the report",
            "format": "int32"
          },
          "startDate": {
            "type": "string",
            "description": "The window the report covers (inclusive)",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "The window end the report covers (inclusive)",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "Headline aggregates for the Cost & Profit report"
      },
      "CreateAdHocChargeRequest": {
        "required": [
          "billingDate",
          "description",
          "unitPrice"
        ],
        "type": "object",
        "properties": {
          "description": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "The invoice line description"
          },
          "quantity": {
            "type": "number",
            "description": "The quantity (defaults to 1)",
            "format": "double"
          },
          "unitPrice": {
            "type": "number",
            "description": "The unit price",
            "format": "double"
          },
          "billingDate": {
            "type": "string",
            "description": "The date to bill the charge on",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "Request to add a one-off charge to a client's billing schedule. It bills on the given date like\nany other scheduled item; VAT follows the client's VAT treatment and the accounting code is the\ntenant default, both correctable on the line before it is invoiced."
      },
      "CreateAmlClientRequest": {
        "required": [
          "clientCode",
          "contacts",
          "name"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "minLength": 1,
            "type": "string"
          },
          "externalReference": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "minLength": 1,
            "type": "string"
          },
          "isIndividual": {
            "type": "boolean"
          },
          "isSoleTrader": {
            "type": "boolean",
            "description": "The Sodium client is a sole trader. Firmcheck creates these as a sole trader (trading name\nover one individual); Xama ignores the flag."
          },
          "regNumber": {
            "type": "string",
            "nullable": true
          },
          "contacts": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreateAmlContactRequest"
            }
          }
        },
        "additionalProperties": false
      },
      "CreateAmlContactRequest": {
        "required": [
          "email",
          "firstName",
          "lastName"
        ],
        "type": "object",
        "properties": {
          "contactCode": {
            "type": "string",
            "description": "The Sodium client-contact code. Used to store the AML contact ID back after creation.",
            "nullable": true
          },
          "firstName": {
            "minLength": 1,
            "type": "string"
          },
          "lastName": {
            "minLength": 1,
            "type": "string"
          },
          "email": {
            "minLength": 1,
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CreateApiKeyRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The friendly name for this API key"
          },
          "tenantCode": {
            "type": "string",
            "description": "The tenant to scope this key to (required when scoping to a role)",
            "nullable": true
          },
          "systemRoleType": {
            "$ref": "#/components/schemas/SystemRole"
          },
          "roleCode": {
            "type": "string",
            "description": "The code of the custom role to scope to. Supply either this or SystemRoleType, not both.",
            "nullable": true
          },
          "isSendBlocked": {
            "type": "boolean",
            "description": "Block this key from every endpoint that sends a message (email, SMS, WhatsApp), whatever\nits role allows: it can still create and edit drafts. Defaults to false."
          }
        },
        "additionalProperties": false,
        "description": "Request to create a new API key. Leave the scope fields empty for a normal key that fully\nimpersonates you. Supply a tenant + role to create a scoped key: it only works on that\ntenant, and its effective permissions are the role's, capped at whatever you yourself hold\nthere at the time of each request."
      },
      "CreateBillableServiceRequest": {
        "required": [
          "categoryCode",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the service"
          },
          "description": {
            "type": "string",
            "description": "The description of the service",
            "nullable": true
          },
          "clientTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "The types of clients this service is applicable to.\nAn empty list means the service is applicable to all client types.",
            "nullable": true
          },
          "agentAuthorisations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentAuthorisationType"
            },
            "description": "The HMRC agent authorisation types relevant to this service",
            "nullable": true
          },
          "requiredProducts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SodiumProduct"
            },
            "description": "The Sodium products this service is powered by. A client taking the service gets each\nproduct's tab on their record.",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "Indicates whether this service is archived (inactive)"
          },
          "accountingCode": {
            "maxLength": 20,
            "minLength": 0,
            "type": "string",
            "description": "The accounting code for this service (max 20 characters)",
            "nullable": true
          },
          "defaultManagedByUserCode": {
            "type": "string",
            "description": "The code of the user who is the default manager for this service",
            "nullable": true
          },
          "serviceScheduleContentCode": {
            "type": "string",
            "description": "The code of the content block to use for service schedule",
            "nullable": true
          },
          "proposalContentCode": {
            "type": "string",
            "description": "The code of the content block to use for proposals",
            "nullable": true
          },
          "categoryCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the category for this service"
          },
          "vatRate": {
            "$ref": "#/components/schemas/VatRate"
          },
          "pricingMode": {
            "$ref": "#/components/schemas/ServicePricingMode"
          },
          "pricingTiers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServicePricingTierDto"
            },
            "description": "Custom pricing tiers. Required when PricingMode = CustomTiers.",
            "nullable": true
          },
          "showKanbanBoard": {
            "type": "boolean",
            "description": "Whether this service should appear on the Boards kanban view"
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServiceStageDto"
            },
            "description": "User-defined workflow stages for this service",
            "nullable": true
          },
          "pricing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServicePricingOptionDto"
            },
            "description": "The pricing options for this service",
            "nullable": true
          },
          "pricingFactors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PricingFactorDto"
            },
            "description": "The pricing factors that can affect the service pricing calculations",
            "nullable": true
          },
          "pcrItemCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of professional clearance request items for this service",
            "nullable": true
          },
          "invoiceLineDescriptionTemplate": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "Smart name token template for invoice line descriptions (e.g. \"{{ ServiceName }} - {{ Month }} {{ Year }}\")",
            "nullable": true
          },
          "setupFee": {
            "type": "number",
            "description": "Optional one-off setup fee charged when the service is first billed for a client.\nNull means no setup fee.",
            "format": "double",
            "nullable": true
          },
          "pricingBasis": {
            "$ref": "#/components/schemas/PricingBasis"
          },
          "unitName": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The unit label for PerUnit pricing (e.g. \"employee\", \"timesheet\").\nRequired when PricingBasis is PerUnit, must be blank otherwise.",
            "nullable": true
          },
          "quantityVariesPerPeriod": {
            "type": "boolean",
            "description": "Whether the billed quantity is expected to change from period to period. When true (default),\ngenerated billing lines for non-Fixed services are always created Pending so the quantity can be\nconfirmed before invoicing, regardless of the approval settings. Used as the default when\nassigning the service to a client. Ignored when PricingBasis is Fixed."
          },
          "defaultUnitQuantity": {
            "maximum": 9999999,
            "minimum": 0,
            "type": "number",
            "description": "The typical quantity per billing period, used as the default when assigning the service to a\nclient. Null means the volume is unknown. Ignored when PricingBasis is Fixed.",
            "format": "double",
            "nullable": true
          },
          "supportsCatchUpFees": {
            "type": "boolean",
            "description": "Whether a catch-up fee can be agreed when this service is assigned to a client. On by\ndefault; switch it off for services where catching up on backlog makes no sense."
          },
          "billingTiming": {
            "$ref": "#/components/schemas/BillingTiming"
          },
          "compoundPercentageFactors": {
            "type": "boolean",
            "description": "Whether percentage pricing factors compound (+20% and +10% is +32%) rather than\nadd (+30%). Fixed-amount factors are added afterwards either way."
          },
          "hasPreparerRole": {
            "type": "boolean",
            "description": "Whether clients on this service have a Preparer. When on, the Preparer is asked for when the\nservice is assigned to a client, and tasks and steps can be assigned to them."
          },
          "defaultPreparerUserCode": {
            "type": "string",
            "description": "The code of the user who is the default Preparer when the service is assigned to a client",
            "nullable": true
          },
          "hasReviewerRole": {
            "type": "boolean",
            "description": "Whether clients on this service have a Reviewer. When on, the Reviewer is asked for when the\nservice is assigned to a client, and tasks and steps can be assigned to them."
          },
          "defaultReviewerUserCode": {
            "type": "string",
            "description": "The code of the user who is the default Reviewer when the service is assigned to a client",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new billable service"
      },
      "CreateCalendarSubscriptionRequest": {
        "required": [
          "color",
          "url"
        ],
        "type": "object",
        "properties": {
          "url": {
            "maxLength": 2048,
            "minLength": 1,
            "type": "string",
            "description": "The ICS feed URL — https:// or webcal:// (Google's \"Secret address in iCal format\",\nOutlook's published ICS link, or Apple's public calendar link)."
          },
          "name": {
            "maxLength": 200,
            "type": "string",
            "description": "Display name. When omitted, the feed's own calendar name is used.",
            "nullable": true
          },
          "color": {
            "maxLength": 7,
            "minLength": 1,
            "pattern": "^#[0-9a-fA-F]{6}$",
            "type": "string",
            "description": "Hex display colour for events from this calendar (e.g. \"#3B82F6\")."
          }
        },
        "additionalProperties": false,
        "description": "Request to subscribe to an external calendar by ICS URL. The URL is validated by fetching it,\nso a bad link fails here rather than creating a broken subscription."
      },
      "CreateClientBillableServiceRequest": {
        "required": [
          "billableServiceCode",
          "billingFrequency",
          "startDate"
        ],
        "type": "object",
        "properties": {
          "billableServiceCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the billable service to assign to this client"
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "price": {
            "type": "number",
            "description": "The base price for this client's service (before any adjustment).\nThe final price is: Price + (Price * PriceAdjustmentPercentage / 100) + PriceAdjustmentFixedAmount.\nRequired when OverridePricing = true; ignored when OverridePricing = false (price comes from BillableService).\nNegative values are allowed (e.g. discounts / credit lines on a proposal).",
            "format": "double",
            "nullable": true
          },
          "overridePricing": {
            "type": "boolean",
            "description": "Indicates whether to use a custom Price value instead of BillableService pricing\nIf true: Must provide Price value\nIf false: Price is loaded from BillableService, and the client-level adjustment is applied"
          },
          "priceAdjustmentPercentage": {
            "type": "number",
            "description": "Percentage contribution from selected Percentage-mode pricing factors (positive or negative). Use -10 for 10% discount, 20 for 20% markup. Defaults to 0.",
            "format": "double"
          },
          "priceAdjustmentFixedAmount": {
            "type": "number",
            "description": "Absolute currency contribution from selected FixedAmount-mode pricing factors (positive or negative). Defaults to 0.",
            "format": "double"
          },
          "startDate": {
            "type": "string",
            "description": "The start date for this service",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "The end date for this service (optional - null means ongoing)",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "managedByUserCode": {
            "type": "string",
            "description": "The code of the user managing this service",
            "nullable": true
          },
          "preparerUserCode": {
            "type": "string",
            "description": "The code of the user who prepares the work. Ignored while the service has no Preparer role:\nan update then keeps the stored Preparer.",
            "nullable": true
          },
          "reviewerUserCode": {
            "type": "string",
            "description": "The code of the user who reviews the work. Ignored while the service has no Reviewer role:\nan update then keeps the stored Reviewer.",
            "nullable": true
          },
          "pricingAnswers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The pricing factor answers that determined the final price\nKey: Question, Value: Answer",
            "nullable": true
          },
          "pricingTierCode": {
            "type": "string",
            "description": "The code of the custom pricing tier to apply. Required when the BillableService uses CustomTiers and OverridePricing = false.",
            "nullable": true
          },
          "stageCode": {
            "type": "string",
            "description": "The code of the current workflow stage to set on this service (optional)",
            "nullable": true
          },
          "servicePackageCode": {
            "type": "string",
            "description": "The code of the service package this service was created from, if any.\nLinks the service to its originating package for display and pricing purposes.",
            "nullable": true
          },
          "overrideServicePackagePrice": {
            "type": "boolean",
            "description": "Whether the package-level price is agreed for this client rather than inherited from the\npackage: the package-level twin of SodiumHQ.DTOs.ClientBillableService.CreateClientBillableServiceRequest.OverridePricing. True, send the agreed figure\nin SodiumHQ.DTOs.ClientBillableService.CreateClientBillableServiceRequest.ServicePackagePrice on every member of the package. False, the price is\nstamped from the package as it stands (bug 2328), and an update that turns the flag off\nre-stamps from the package."
          },
          "servicePackagePrice": {
            "type": "number",
            "description": "The package-level price for a member of a package-priced package. Required when\nSodiumHQ.DTOs.ClientBillableService.CreateClientBillableServiceRequest.OverrideServicePackagePrice is true; ignored otherwise, where the price is\nstamped from the package.",
            "format": "double",
            "nullable": true
          },
          "servicePackageBillingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "setupFee": {
            "type": "number",
            "description": "The one-off setup fee for this client's service. Null means no setup fee.\nWhen OverrideSetupFee = false, pass the BillableService.SetupFee default (or null).\nWhen OverrideSetupFee = true, pass the custom fee (null/0 removes the fee for this client).",
            "format": "double",
            "nullable": true
          },
          "overrideSetupFee": {
            "type": "boolean",
            "description": "Indicates whether to use a custom SetupFee value instead of the BillableService default"
          },
          "autoInvoice": {
            "type": "boolean",
            "description": "Whether this service is on the billing schedule. On: occurrences are generated from the start\ndate, frequency and end date, and due ones become billing lines nightly. Off: the service is\nbilled outside Sodium."
          },
          "setupFeeBillingMoment": {
            "$ref": "#/components/schemas/SetupFeeBillingMoment"
          },
          "billingTiming": {
            "$ref": "#/components/schemas/BillingTiming"
          },
          "catchUp": {
            "$ref": "#/components/schemas/CatchUpFeeDto"
          },
          "overrideCatchUpFee": {
            "type": "boolean",
            "description": "Whether the catch-up fee was agreed for this client rather than worked out as the months times\nthe monthly-equivalent rate. Ignored (stored false) when there is no catch-up fee."
          },
          "unitQuantity": {
            "type": "number",
            "description": "The expected quantity per billing period for services with a non-Fixed pricing basis\n(e.g. 12 employees). Null means the volume is unknown. Ignored for Fixed services.",
            "format": "double",
            "nullable": true
          },
          "quantityVariesPerPeriod": {
            "type": "boolean",
            "description": "Whether the billed quantity is expected to change from period to period. When true (default),\ngenerated billing lines for this service are always created Pending so the quantity can be\nconfirmed before invoicing, regardless of the approval settings. Seeded from the\nBillableService default at assignment. Ignored for Fixed services."
          },
          "createOnboardingTasks": {
            "type": "boolean",
            "description": "Whether to create the service's onboarding tasks when it is added as Active, or an update moves\nit from Proposed to Active. Defaults to true. Set to false when back-filling a service the\nclient already has, so no tasks are created for work already done."
          },
          "notes": {
            "type": "string",
            "description": "The practice's own notes on this client's service, as HTML (plain text is accepted and kept\nwith its line breaks). Optional. Ignored on an update, which keeps the stored notes: change them\nwith the client service notes endpoint.",
            "nullable": true
          },
          "showNotesOnCard": {
            "type": "boolean",
            "description": "Whether the notes show on the service's card on the client's Services tab. Defaults to true.\nIgnored on an update, like SodiumHQ.DTOs.ClientBillableService.CreateClientBillableServiceRequest.Notes."
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new client billable service assignment"
      },
      "CreateClientBillingLineItemRequest": {
        "required": [
          "billingDate",
          "description",
          "unitPrice"
        ],
        "type": "object",
        "properties": {
          "clientBillableServiceCode": {
            "type": "string",
            "description": "The code of the client billable service to link this line item to (optional)",
            "nullable": true
          },
          "description": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "The invoice line description"
          },
          "quantity": {
            "type": "number",
            "description": "The quantity (defaults to 1)",
            "format": "double"
          },
          "unitPrice": {
            "type": "number",
            "description": "The unit price",
            "format": "double"
          },
          "vatRate": {
            "$ref": "#/components/schemas/VatRate"
          },
          "accountingCode": {
            "maxLength": 20,
            "type": "string",
            "description": "The accounting/nominal code (optional)",
            "nullable": true
          },
          "periodStart": {
            "type": "string",
            "description": "Start of the service period covered (optional)",
            "format": "date-time",
            "nullable": true
          },
          "periodEnd": {
            "type": "string",
            "description": "End of the service period covered (optional)",
            "format": "date-time",
            "nullable": true
          },
          "billingDate": {
            "type": "string",
            "description": "Target invoice date",
            "format": "date-time"
          },
          "invoiceNow": {
            "type": "boolean",
            "description": "Creates the line approved and invoices it straight away, on its own invoice dated its billing\ndate. Refused before anything is created when the practice has no accounting connection or\nthe client has no accounting customer mapping."
          }
        },
        "additionalProperties": false,
        "description": "Request to manually create a billing line item for a client"
      },
      "CreateClientContactRequest": {
        "required": [
          "types"
        ],
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "description": "The role of the contact within this client relationship",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "The type of contact relationship"
          },
          "contact": {
            "$ref": "#/components/schemas/ContactDto"
          },
          "resignedDate": {
            "type": "string",
            "description": "Date the contact resigned their officer role for this client. Usually populated by the\nCompanies House officer stream; user-editable so it can also be set manually (or cleared).",
            "format": "date",
            "nullable": true
          },
          "ceasedDate": {
            "type": "string",
            "description": "Date the contact ceased being a Person with Significant Control for this client. Usually\npopulated by the Companies House PSC stream; user-editable so it can also be set manually.",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new client-contact relationship"
      },
      "CreateClientDocumentFromTemplateRequest": {
        "required": [
          "templateCode",
          "title"
        ],
        "type": "object",
        "properties": {
          "templateCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the document template to render."
          },
          "designThemeCode": {
            "type": "string",
            "description": "Optional design theme code. If not specified, the template's default or tenant default is used.",
            "nullable": true
          },
          "title": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "Title for the generated document."
          },
          "summary": {
            "maxLength": 2000,
            "type": "string",
            "description": "Optional summary/description for the generated document.",
            "nullable": true
          },
          "documentCategoryCode": {
            "type": "string",
            "description": "Optional document category code.",
            "nullable": true
          },
          "customTokens": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Custom token values to inject into the template. Keys are token names, values are the text to substitute.\nAccessible in templates as {{ CustomFields.TokenName }}.",
            "nullable": true
          },
          "visibleInClientPortal": {
            "type": "boolean",
            "description": "Whether the generated document should be visible in the client portal. Defaults to true."
          },
          "portalFolderPath": {
            "type": "string",
            "description": "Portal folder path for the generated document. When not specified, the practice's filing folder for generated documents (Settings, Document Storage, Filing).\n\"/\" is the top of the portal.",
            "nullable": true
          },
          "storageFolderPath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for the generated document. When not specified, the\npractice's filing folder for generated documents. \"/\" is the client's folder itself.",
            "nullable": true
          },
          "taskCode": {
            "type": "string",
            "description": "Optional code of the client's task the document is generated for (a workflow step's document): its period\ntokens then name the task's tax month, else its start date's periods, instead of today's.",
            "nullable": true
          },
          "editedHtml": {
            "type": "string",
            "description": "The body to use instead of the template's, when the user edited it first: the html from the editable-html route,\nchanged. It is not parsed as a template. The token values are still needed for the theme's header and footer.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to generate a PDF document from a template and save it as a client document."
      },
      "CreateClientEmailRuleRequest": {
        "required": [
          "value"
        ],
        "type": "object",
        "properties": {
          "value": {
            "maxLength": 255,
            "minLength": 0,
            "type": "string",
            "description": "The email address, domain, or message ID to match.\nEmail addresses (contain '@') match that specific participant.\nDomains (no '@', not a GUID) match all emails from that domain.\nMessage IDs (valid GUID) pin a specific email to this client."
          }
        },
        "additionalProperties": false,
        "description": "Request to create a new email rule for a client.\nProvide an email address (e.g. \"john@acme.com\") to match that participant,\na domain (e.g. \"acme.com\") to match all emails from that domain,\nor a message ID (GUID) to pin a specific email to this client."
      },
      "CreateClientLinkRequest": {
        "required": [
          "linkType",
          "url"
        ],
        "type": "object",
        "properties": {
          "url": {
            "minLength": 1,
            "type": "string",
            "description": "The URL of the link",
            "format": "uri"
          },
          "linkType": {
            "$ref": "#/components/schemas/LinkType"
          },
          "displayName": {
            "maxLength": 200,
            "type": "string",
            "description": "Optional display name shown as anchor text instead of the URL",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new client link"
      },
      "CreateClientNoteRequest": {
        "required": [
          "date",
          "text"
        ],
        "type": "object",
        "properties": {
          "text": {
            "minLength": 1,
            "type": "string",
            "description": "The text content of the note"
          },
          "date": {
            "type": "string",
            "description": "The date/time the note was created",
            "format": "date-time"
          },
          "noteFromUserCode": {
            "type": "string",
            "description": "The code of the user who authored this note. Defaults to the authenticated user if not provided.",
            "nullable": true
          },
          "pinnedLevel": {
            "type": "integer",
            "description": "The pinned level: 0 not pinned, 1 top of the notes section, 2 top of the client or task page, 3 the dashboard",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new client note"
      },
      "CreateClientPipelineRequest": {
        "required": [
          "pipelineCode",
          "startDate"
        ],
        "type": "object",
        "properties": {
          "pipelineCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the pipeline to place the client on"
          },
          "stageCode": {
            "type": "string",
            "description": "The code of the initial stage (optional — null means no stage yet)",
            "nullable": true
          },
          "managedByUserCode": {
            "type": "string",
            "description": "The code of the user managing this card (optional)",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "The date the client entered the pipeline",
            "format": "date-time"
          },
          "value": {
            "maximum": 99999999.99,
            "minimum": 0,
            "type": "number",
            "description": "What the deal is worth if it closes (optional)",
            "format": "double",
            "nullable": true
          },
          "likelihood": {
            "maximum": 100,
            "minimum": 0,
            "type": "integer",
            "description": "How likely the deal is to close, as a percentage 0-100 (optional)",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for placing a client on a sales pipeline (creating a card)"
      },
      "CreateClientRequest": {
        "required": [
          "name",
          "type"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the client"
          },
          "type": {
            "$ref": "#/components/schemas/ClientType"
          },
          "internalReference": {
            "type": "string",
            "description": "Optional internal reference number/code for the client",
            "nullable": true
          },
          "managerCode": {
            "type": "string",
            "description": "Code of the user who will manage this client.\nThe user must exist and have access to the tenant.",
            "nullable": true
          },
          "partnerCode": {
            "type": "string",
            "description": "Code of the user who will be the partner for this client.\nThe user must exist and have access to the tenant.",
            "nullable": true
          },
          "associateCode": {
            "type": "string",
            "description": "Code of the user who will be the associate for this client.\nThe user must exist and have access to the tenant.",
            "nullable": true
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of teams to assign to this client",
            "nullable": true
          },
          "isAccessRestricted": {
            "type": "boolean",
            "description": "When true, only the people in AccessUserCodes may see this client, on top of the usual visibility rule.\nNull leaves the client's setting as it is. Switching it on adds the saving user to the list.",
            "nullable": true
          },
          "accessUserCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the users who may see this client while its access is restricted. Null leaves the list as it is.\nThe saving user must be on it while access is restricted.",
            "nullable": true
          },
          "revenueRangeCode": {
            "type": "string",
            "description": "The revenue range code for this client",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ClientStatus"
          },
          "accountingCustomerCode": {
            "type": "string",
            "description": "The customer code/ID from the connected accounting platform",
            "nullable": true
          },
          "directDebitMandateId": {
            "type": "string",
            "description": "The mandate ID from the connected direct debit platform",
            "nullable": true
          },
          "amlClientId": {
            "type": "string",
            "description": "The client/account ID from the connected AML platform",
            "nullable": true
          },
          "amlClientName": {
            "type": "string",
            "description": "The display name of the client in the connected AML platform",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The email address for the client",
            "nullable": true
          },
          "alternativeEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional email addresses for the client. Email remains the primary address.\nBlank entries and duplicates of the primary address are discarded.",
            "nullable": true
          },
          "telephone": {
            "type": "string",
            "description": "The telephone number for the client",
            "nullable": true
          },
          "alternativePhoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional phone numbers for the client. Telephone remains the primary number.\nBlank entries and duplicates of the primary number are discarded.",
            "nullable": true
          },
          "contactPreferences": {
            "$ref": "#/components/schemas/ContactPreferencesDto"
          },
          "invoiceDayOfMonth": {
            "type": "integer",
            "description": "Day of month (1-28) for automatic invoicing. Null disables auto-invoicing.",
            "format": "int32",
            "nullable": true
          },
          "invoicePaymentTermDays": {
            "type": "integer",
            "description": "Payment terms in days for generated invoices",
            "format": "int32",
            "nullable": true
          },
          "lineItemApprovalRequired": {
            "type": "boolean",
            "description": "Null = use tenant default. True = require manual approval. False = auto-approve.",
            "nullable": true
          },
          "vatTreatment": {
            "$ref": "#/components/schemas/ClientVatTreatment"
          },
          "pclSent": {
            "type": "boolean",
            "description": "Indicates whether a Professional Clearance Letter has been sent for this client"
          },
          "snoozeChasesUntil": {
            "type": "string",
            "description": "Suppresses automated chase emails for this client until this date (chasing resumes on the date itself).\nNull = chases are not snoozed.",
            "format": "date-time",
            "nullable": true
          },
          "businessDetails": {
            "$ref": "#/components/schemas/BusinessDetailsDto"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new client"
      },
      "CreateContactRequest": {
        "type": "object",
        "properties": {
          "title": {
            "maxLength": 20,
            "type": "string",
            "description": "The contact's title (e.g., Mr, Mrs, Ms, Dr)",
            "nullable": true
          },
          "firstName": {
            "maxLength": 100,
            "type": "string",
            "description": "The contact's first name",
            "nullable": true
          },
          "middleName": {
            "maxLength": 100,
            "type": "string",
            "description": "The contact's middle name",
            "nullable": true
          },
          "lastName": {
            "maxLength": 100,
            "type": "string",
            "description": "The contact's last name",
            "nullable": true
          },
          "preferredName": {
            "maxLength": 100,
            "type": "string",
            "description": "The name the contact goes by, when different from their first name (e.g. Matt for Matthias)",
            "nullable": true
          },
          "email": {
            "maxLength": 200,
            "type": "string",
            "description": "The contact's email address",
            "nullable": true
          },
          "alternativeEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional email addresses the contact also uses. Email remains the primary\naddress and is the default for outgoing communication. Blank entries and\nduplicates of the primary address are discarded.",
            "nullable": true
          },
          "phone": {
            "maxLength": 50,
            "type": "string",
            "description": "The contact's landline phone number",
            "nullable": true
          },
          "mobile": {
            "maxLength": 50,
            "type": "string",
            "description": "The contact's mobile phone number",
            "nullable": true
          },
          "alternativePhoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional phone numbers the contact also uses. Phone and Mobile remain the\nprimary numbers. Blank entries and duplicates of the primary numbers are discarded.",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "description": "The contact's date of birth",
            "format": "date",
            "nullable": true
          },
          "utr": {
            "type": "string",
            "description": "The contact's Unique Taxpayer Reference (Self Assessment UTR).\nUsed for individuals' personal tax affairs.",
            "nullable": true
          },
          "niNumber": {
            "type": "string",
            "description": "The contact's National Insurance Number.",
            "nullable": true
          },
          "cgtReference": {
            "maxLength": 20,
            "type": "string",
            "description": "The contact's Capital Gains Tax on UK property account number, issued by HMRC when they\nfirst report a property disposal.",
            "nullable": true
          },
          "personalCode": {
            "maxLength": 50,
            "type": "string",
            "description": "The contact's Companies House person ID code, used to uniquely identify\nan individual within the Companies House system.",
            "nullable": true
          },
          "address": {
            "type": "string",
            "description": "The contact's address. Only used when the client type is Individual.",
            "nullable": true
          },
          "nationality": {
            "$ref": "#/components/schemas/Nationality"
          },
          "maritalStatus": {
            "$ref": "#/components/schemas/MaritalStatus"
          },
          "isDeceased": {
            "type": "boolean",
            "description": "Whether this contact is deceased"
          },
          "deceasedDate": {
            "type": "string",
            "description": "The date the contact was deceased, if known",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a contact"
      },
      "CreateContentBlockRequest": {
        "required": [
          "category",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "Display name for the content block (e.g., \"Standard Header\", \"Legal Footer\", \"Signature Block\")"
          },
          "bodyHtml": {
            "type": "string",
            "description": "HTML content of the block with Liquid syntax support.\nContent blocks receive the same token context as the parent template, allowing them to access:\n- All data passed to the template (client, services, custom fields)\n- System-provided tokens (tenant, date)\n- Nested content blocks using {{ contentBlock \"another-block\" }}\n\nExample header block:\n\n<header>\n  <h1>{{ tenant.name }}</h1>\n  <p>{{ tenant.address.line1 }}, {{ tenant.address.city }}</p>\n  <p>Date: {{ date | date: \"%B %d, %Y\" }}</p>\n</header>\n\n\nExample conditional footer:\n\n<footer>\n  {% if client.isVatRegistered %}\n  <p>VAT Number: {{ client.vatNumber }}</p>\n  {% endif %}\n  <p>© {{ date | date: \"%Y\" }} {{ tenant.name }}</p>\n</footer>",
            "nullable": true
          },
          "description": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "Optional description explaining the block's purpose and where it should be used",
            "nullable": true
          },
          "category": {
            "$ref": "#/components/schemas/ContentBlockCategory"
          },
          "subjectLine": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "Optional subject line for email content blocks (only relevant when Category is EmailParts).\nSupports merge field syntax (e.g., {{ Client.Name }}).",
            "nullable": true
          },
          "libraryCode": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "Optional reference to the library item code this content block was imported from.\nUsed to track the origin of content blocks created from the library.\nCan only be set during creation and cannot be modified later.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a new reusable content block that can be included in document templates.\nContent blocks are shared sections of content that maintain consistency across documents."
      },
      "CreateCsvMappingRequest": {
        "required": [
          "columnMappings",
          "mappingType",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "Human-readable display name for this mapping.\nChoose a descriptive name that identifies the CSV format (e.g., 'IRIS Export', 'Xero Contacts').\nRequired.",
            "example": "IRIS Client Export"
          },
          "columnMappings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CsvColumnMappingDto"
            },
            "description": "The column mappings that define how CSV headers map to client fields.\nEach mapping specifies a CSV header and the corresponding target field.\nRequired - must include at least one mapping."
          },
          "matchField": {
            "$ref": "#/components/schemas/CsvImportMatchField"
          },
          "mappingType": {
            "$ref": "#/components/schemas/CsvMappingType"
          }
        },
        "additionalProperties": false,
        "description": "Request to create a new reusable CSV mapping.\nSaved mappings can be referenced by code in future imports/exports,\neliminating the need to specify column mappings each time."
      },
      "CreateCustomFieldDefinitionRequest": {
        "required": [
          "customFieldGroupCode"
        ],
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "nullable": true
          },
          "entityType": {
            "$ref": "#/components/schemas/CustomFieldEntityType"
          },
          "dataType": {
            "$ref": "#/components/schemas/CustomFieldDataType"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "maxLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "lines": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "displayWidth": {
            "$ref": "#/components/schemas/FieldDisplayWidth"
          },
          "booleanDisplayMode": {
            "$ref": "#/components/schemas/BooleanDisplayMode"
          },
          "isFullRow": {
            "type": "boolean",
            "description": "Whether the field takes a whole row of its card on the record, rather than one column of it.\nDisplayWidth then applies within that row. Only for types whose metadata has HasFullRow."
          },
          "numberDecimalPlaces": {
            "maximum": 2,
            "minimum": 0,
            "type": "integer",
            "description": "Number fields only: decimal places the value renders with in templates (0 to 2). Null keeps the decimals as entered.",
            "format": "int32",
            "nullable": true
          },
          "numberThousandsSeparator": {
            "type": "boolean",
            "description": "Number fields only: whether the value renders in templates with a thousands separator."
          },
          "numberCurrencySymbol": {
            "type": "boolean",
            "description": "Number fields only: whether the value renders in templates with the practice currency symbol."
          },
          "clientTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "The types of clients this custom field is applicable to.\nAn empty list means the field is applicable to all client types.",
            "nullable": true
          },
          "billableServiceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the services a client must hold for this custom field to apply to them.\nAn empty list means the field applies regardless of the client's services.",
            "nullable": true
          },
          "isRequired": {
            "type": "boolean",
            "description": "Whether a value must be held for this field on every client the field applies to.\nA required field restricted by client type or by service is required only on the clients\nit applies to."
          },
          "customFieldGroupCode": {
            "minLength": 1,
            "type": "string"
          },
          "sortOrder": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "CreateCustomFieldGroupRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string"
          },
          "entityType": {
            "$ref": "#/components/schemas/CustomFieldEntityType"
          },
          "parentCustomFieldGroupCode": {
            "type": "string",
            "nullable": true
          },
          "condition": {
            "$ref": "#/components/schemas/ConditionDto"
          },
          "sortOrder": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "CreateCustomTokenRequest": {
        "required": [
          "name",
          "tokenIdentifier"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 120,
            "minLength": 1,
            "type": "string",
            "description": "Human-readable display name for the token (e.g. \"Company Secretary\")"
          },
          "tokenIdentifier": {
            "maxLength": 120,
            "minLength": 1,
            "type": "string",
            "description": "The token identifier used in templates (e.g. \"CompanySecretary\" for {{ Custom.CompanySecretary }}).\nMust be alphanumeric with underscores only. Unique per tenant."
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional prompt text shown when filling in the token value",
            "nullable": true
          },
          "defaultValue": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional default value pre-populated in the token form",
            "nullable": true
          },
          "displayWidth": {
            "type": "string",
            "description": "Preset display width for the input. Null defaults to Full.",
            "nullable": true
          },
          "lines": {
            "type": "integer",
            "description": "Number of visible text lines. Null renders a single-line input, 2+ renders a textarea.",
            "format": "int32",
            "nullable": true
          },
          "isRichText": {
            "type": "boolean",
            "description": "When true and Lines >= 2, the input renders as a rich text editor instead of a plain textarea."
          },
          "isNumber": {
            "type": "boolean",
            "description": "When true the value is a number: the input takes a number and the token renders with the number format."
          },
          "numberDecimalPlaces": {
            "maximum": 2,
            "minimum": 0,
            "type": "integer",
            "description": "Number tokens only: decimal places the value renders with (0 to 2). Null keeps the decimals as entered.",
            "format": "int32",
            "nullable": true
          },
          "numberThousandsSeparator": {
            "type": "boolean",
            "description": "Number tokens only: whether the value renders with a thousands separator."
          },
          "numberCurrencySymbol": {
            "type": "boolean",
            "description": "Number tokens only: whether the value renders with the practice currency symbol."
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a custom token"
      },
      "CreateCustomerRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The customer or company name",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The customer's email address",
            "nullable": true
          },
          "contactNumber": {
            "type": "string",
            "description": "The customer's phone number",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "description": "The contact person's first name",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "description": "The contact person's last name",
            "nullable": true
          },
          "platformData": {
            "type": "object",
            "additionalProperties": { },
            "description": "Platform-specific data required for customer creation",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a customer in an accounting platform"
      },
      "CreateDashboardLinkRequest": {
        "required": [
          "scope",
          "url"
        ],
        "type": "object",
        "properties": {
          "scope": {
            "$ref": "#/components/schemas/DashboardLinkScope"
          },
          "url": {
            "maxLength": 2000,
            "minLength": 1,
            "type": "string",
            "description": "Where the link goes. https:// is assumed when no scheme is given; only http and https are accepted."
          },
          "title": {
            "maxLength": 200,
            "type": "string",
            "description": "What to call the link. Optional: without one the URL is shown.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for adding a link to the end of a dashboard list"
      },
      "CreateDataFormCategoryRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The display name of the form category",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a form category"
      },
      "CreateDataFormPreviewTokenResult": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CreateDataFormRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "introduction": {
            "type": "string",
            "nullable": true
          },
          "dataFormCategoryCode": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/DataFormStatus"
          },
          "defaultMessage": {
            "type": "string",
            "nullable": true
          },
          "exportDocumentTemplateCode": {
            "type": "string",
            "description": "Code of the Form Answers template to export the form's answers with: one of this form's own. Null for the\nBasic layout. A save without it puts the form back on Basic.",
            "nullable": true
          },
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormSectionDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating or updating a form (whole-form save including sections and questions)"
      },
      "CreateDesignThemeRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name for the theme",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether this should be the default theme for the tenant"
          },
          "heading1": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "heading2": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "heading3": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "body": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "tableHeader": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "tableCell": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "logoUrl": {
            "type": "string",
            "description": "URL to the company logo image",
            "nullable": true
          },
          "primaryColor": {
            "type": "string",
            "description": "Primary brand color in hex format (e.g., \"#000000\")",
            "nullable": true
          },
          "secondaryColor": {
            "type": "string",
            "description": "Secondary brand color in hex format",
            "nullable": true
          },
          "accentColor": {
            "type": "string",
            "description": "Accent color in hex format",
            "nullable": true
          },
          "backgroundColor": {
            "type": "string",
            "description": "Optional page background color in hex format (e.g., \"#FFFFFF\"). Null for transparent/default.",
            "nullable": true
          },
          "linkColor": {
            "type": "string",
            "description": "Optional link color in hex format (e.g., \"#1E88E5\"). Null for default.",
            "nullable": true
          },
          "linkHoverColor": {
            "type": "string",
            "description": "Optional link hover color in hex format (e.g., \"#0D47A1\"). Null for default.",
            "nullable": true
          },
          "primaryButton": {
            "$ref": "#/components/schemas/ButtonStyleDto"
          },
          "secondaryButton": {
            "$ref": "#/components/schemas/ButtonStyleDto"
          },
          "navBackgroundColor": {
            "type": "string",
            "description": "Navigation background color for the client portal (e.g., \"#1e293b\")",
            "nullable": true
          },
          "navTextColor": {
            "type": "string",
            "description": "Navigation text color for the client portal",
            "nullable": true
          },
          "navActiveBackgroundColor": {
            "type": "string",
            "description": "Active navigation item highlight color (supports rgba, e.g., \"rgba(255,255,255,0.15)\")",
            "nullable": true
          },
          "navActiveTextColor": {
            "type": "string",
            "description": "Active navigation item text color",
            "nullable": true
          },
          "cardBackgroundColor": {
            "type": "string",
            "description": "Card/panel background color in the content area",
            "nullable": true
          },
          "borderRadius": {
            "type": "integer",
            "description": "Global corner radius in pixels for cards, buttons, and inputs",
            "format": "int32",
            "nullable": true
          },
          "navFontSize": {
            "type": "number",
            "description": "Font size in points for the client portal navigation bar. Null falls back to body font size.",
            "format": "float",
            "nullable": true
          },
          "faviconUrl": {
            "type": "string",
            "description": "URL to a tenant-specific favicon for the client portal",
            "nullable": true
          },
          "pageMargins": {
            "$ref": "#/components/schemas/MarginsDto"
          },
          "customCSS": {
            "type": "string",
            "description": "Additional custom CSS rules to append to the generated theme CSS",
            "nullable": true
          },
          "headerTextContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use for document headers.\nPDF only: repeats at the top of each page. When set, PageMarginTop is ignored.",
            "nullable": true
          },
          "headerPageSelection": {
            "$ref": "#/components/schemas/PageSelection"
          },
          "footerContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use for document footers.\nPDF only: repeats at the bottom of each page.",
            "nullable": true
          },
          "footerPageSelection": {
            "$ref": "#/components/schemas/PageSelection"
          },
          "pageNumberDisplay": {
            "$ref": "#/components/schemas/PageSelection"
          }
        },
        "additionalProperties": false,
        "description": "Request to create a new design theme for document styling"
      },
      "CreateDocumentCategoryRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The display name of the document category",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying document categories",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a document category"
      },
      "CreateDocumentRequestItemListRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "What staff pick it by (at most 200 characters)"
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "What the list is for (at most 500 characters)",
            "nullable": true
          },
          "items": {
            "maxItems": 250,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestStepItemDto"
            },
            "description": "The items, in order (at most 250, as on a request); each needs text of at most 1,000 characters",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether \"Use a saved list\" offers it. Defaults to true."
          }
        },
        "additionalProperties": false,
        "description": "A new saved list of document request items"
      },
      "CreateDocumentRequestRequest": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "Title describing what documents are needed",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Detailed description of what is needed",
            "nullable": true
          },
          "deadline": {
            "type": "string",
            "description": "Optional deadline for the client to respond by",
            "format": "date",
            "nullable": true
          },
          "notifyUserCode": {
            "type": "string",
            "description": "Code of the user to notify when a submission is made",
            "nullable": true
          },
          "storageFolderPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Where the request's files are stored, under the client's storage folder, instead of the practice's filing\nfolder for request uploads. May hold tokens (client, dates, Request.Code). Set with the portal folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          },
          "portalFolderPath": {
            "maxLength": 400,
            "type": "string",
            "description": "The client portal folder the request's files are filed in, instead of the practice's filing folder for request\nuploads. May hold tokens. Set with the storage folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestItemInput"
            },
            "description": "Items to ask for one by one: queries to answer or documents to provide. Leave empty for a\nsingle ask, answered and reviewed as a whole.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new document request"
      },
      "CreateDocumentTemplateRequest": {
        "required": [
          "bodyHtml",
          "name",
          "type"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 120,
            "minLength": 1,
            "type": "string",
            "description": "Display name for the template (e.g., \"Standard Engagement Letter\", \"Monthly Report\")"
          },
          "type": {
            "$ref": "#/components/schemas/TemplateType"
          },
          "bodyHtml": {
            "minLength": 1,
            "type": "string",
            "description": "Template body in HTML with Liquid syntax tokens.\nSupported tokens:\n- {{ client.name }} - Client's name\n- {{ client.companyNumber }} - Company registration number\n- {{ tenant.name }} - Your practice name\n- {{ date | date: \"%B %d, %Y\" }} - Current date (formatted)\n- {{ contentBlock \"block-code\" }} - Include a reusable content block\n- {% if client.isVatRegistered %} ... {% endif %} - Conditional content\n- {% for item in services %} ... {% endfor %} - Loop through collections\nCustom tokens can be passed via the Data parameter when rendering."
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional description explaining the template's purpose and usage",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether this template is available for use. Set to false to disable without deleting."
          },
          "outputNameTemplate": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional template for naming rendered documents.\nSupports {{ token }} placeholders (e.g. \"Engagement Letter - {{ ClientName }} - {{ Month }} {{ Year }}\").\nWhen null or empty, documents use the template's Name.",
            "nullable": true
          },
          "defaultDesignThemeCode": {
            "type": "string",
            "description": "Code of the default design theme to apply when rendering this template.\nIf not specified, falls back to the tenant's default theme.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a new document template that can generate documents using Liquid syntax.\nTemplates support tokens for dynamic data replacement and can include reusable content blocks."
      },
      "CreateDraftResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the draft was created successfully"
          },
          "uniqueId": {
            "type": "string",
            "description": "The new draft's UniqueId — use this for subsequent update/send/delete calls.",
            "format": "uuid",
            "nullable": true
          },
          "errorMessage": {
            "type": "string",
            "description": "Error message if creation failed",
            "nullable": true
          },
          "reconnectRequired": {
            "type": "boolean",
            "description": "Whether the user needs to reconnect their mailbox"
          }
        },
        "additionalProperties": false,
        "description": "Response after creating a new mailbox draft."
      },
      "CreateEmailBroadcastRequest": {
        "type": "object",
        "properties": {
          "contentBlockCode": {
            "maxLength": 100,
            "type": "string",
            "description": "Content block code (category: Email) used as the email template.\nMutually exclusive with SubjectLine/BodyHtml — provide one or the other.",
            "nullable": true,
            "example": "client-newsletter"
          },
          "subjectLine": {
            "maxLength": 500,
            "type": "string",
            "description": "Inline email subject line with Liquid template syntax.\nMust be provided together with BodyHtml. Mutually exclusive with ContentBlockCode.",
            "nullable": true,
            "example": "An update for {{ Client.Name }}"
          },
          "bodyHtml": {
            "type": "string",
            "description": "Inline email body HTML with Liquid template syntax.\nMust be provided together with SubjectLine. Mutually exclusive with ContentBlockCode.",
            "nullable": true
          },
          "allContacts": {
            "type": "boolean",
            "description": "When true, every contact of each client with an email address receives the email\nas a To recipient, regardless of contact type. RecipientContactTypes is ignored.",
            "example": false
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include each client's business email (the email address on the client\nrecord) as a To recipient. Applies whether or not AllContacts is set."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for To recipients, resolved per client at send time.\nIgnored when AllContacts is true.",
            "nullable": true
          },
          "recipientUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for To recipients (ClientManager, ClientPartner, ClientAssociate, ClientServiceManager),\nresolved per client at send time. TaskOwner and SpecificUser are not applicable for broadcasts.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to include as To recipients on every email.",
            "nullable": true
          },
          "ccIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include each client's business email as a CC recipient."
          },
          "ccContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for CC recipients.",
            "nullable": true
          },
          "ccUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for CC recipients.",
            "nullable": true
          },
          "ccEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to include as CC recipients on every email.",
            "nullable": true
          },
          "bccIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include each client's business email as a BCC recipient."
          },
          "bccContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for BCC recipients.",
            "nullable": true
          },
          "bccUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for BCC recipients.",
            "nullable": true
          },
          "bccEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to include as BCC recipients on every email.",
            "nullable": true
          },
          "savedViewCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The code of a saved client view whose filter selects which clients to include.\nThe view's criteria are resolved when recipients are resolved, so later changes to\nthe view are picked up until the broadcast is sent. Mutually exclusive with Filter.",
            "nullable": true,
            "example": "active-limited-companies"
          },
          "filter": {
            "$ref": "#/components/schemas/EmailBroadcastFilterDto"
          },
          "excludedClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Client codes to exclude from the filter results.",
            "nullable": true
          },
          "additionalClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hand-picked client codes to add on top of the filter results.",
            "nullable": true
          },
          "onlyEmailableClients": {
            "type": "boolean",
            "description": "When true (default), clients whose email contact preference is not set are skipped.",
            "example": true
          },
          "sendOncePerAddress": {
            "type": "boolean",
            "description": "When true, a contact address on several selected clients gets one copy (the first client's).\nTeam and fixed addresses still go on every client's email.",
            "example": false
          },
          "practiceDocumentCodes": {
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of practice documents (tenant document library) attached to every email\nin the broadcast. Resolved to file content server-side at send time, so the\nbrowser never round-trips the document bytes.",
            "nullable": true
          },
          "addHeaderFooter": {
            "type": "boolean",
            "description": "When true (default), the tenant's email header and footer content blocks are\nwrapped around the body when the email is rendered.",
            "example": true
          },
          "configCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The email configuration (mailbox) code to send from.\nOmit to use the tenant's default mailbox resolution.",
            "nullable": true,
            "example": "billing-mailbox"
          }
        },
        "additionalProperties": false,
        "description": "Request to create a draft email broadcast.\nProvide either a ContentBlockCode or inline SubjectLine + BodyHtml (mutually exclusive).\nRecipient selection combines an optional client filter with hand-picked additions and exclusions."
      },
      "CreateEmailConfigRequest": {
        "required": [
          "fromEmail",
          "providerType"
        ],
        "type": "object",
        "properties": {
          "providerType": {
            "$ref": "#/components/schemas/ProviderType"
          },
          "fromEmail": {
            "minLength": 1,
            "type": "string",
            "description": "The sender email address for this configuration"
          },
          "fromName": {
            "type": "string",
            "description": "The sender display name (optional)",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether to set this as the tenant's default email configuration.\nIf true, IsSendShared must also be true."
          },
          "isSendShared": {
            "type": "boolean",
            "description": "Whether all users in the tenant can send emails from this configuration"
          },
          "readSharing": {
            "$ref": "#/components/schemas/MailboxReadSharing"
          },
          "shareClientEmails": {
            "type": "boolean",
            "description": "With ReadSharing Selected, whether colleagues also see every email with a client. Ignored\n(saved as false) with any other read-sharing."
          },
          "smtpSettings": {
            "$ref": "#/components/schemas/SmtpSettingsRequest"
          },
          "oAuthSettings": {
            "$ref": "#/components/schemas/OAuthSettingsRequest"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new email configuration"
      },
      "CreateEmailTriageStatusRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name, e.g. \"Waiting on client\""
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position in the status picker",
            "format": "int32"
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the status is offered when setting a conversation's status (default true)"
          },
          "color": {
            "maxLength": 20,
            "type": "string",
            "description": "Display colour, e.g. \"#3B82F6\"",
            "nullable": true
          },
          "isDone": {
            "type": "boolean",
            "description": "Whether the status closes a conversation"
          },
          "archiveOnDone": {
            "type": "boolean",
            "description": "Whether setting this status also archives the conversation in Outlook or Gmail. Only allowed with IsDone."
          },
          "archiveFolderName": {
            "maxLength": 255,
            "type": "string",
            "description": "With ArchiveOnDone: the folder path (Gmail: label name) to move the conversation to, matched ignoring case in\neach mailbox; a mailbox without it is left alone. Null or blank for the mailbox's archive.",
            "nullable": true
          },
          "offerOnSend": {
            "type": "boolean",
            "description": "Whether the reply Send button offers this status (\"Send & Done\"). Any status may be offered."
          },
          "onReplyStatusCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The status a client's reply moves the conversation to: an active status that does not mean Done.\nNull: back to the mailbox's default status for a Done status, no move for an open one.",
            "nullable": true
          },
          "bringBackEnabled": {
            "type": "boolean",
            "description": "Whether setting this status also brings the conversation back to SodiumHQ.DTOs.EmailTriage.CreateEmailTriageStatusRequest.BringBackStatusCode after\nSodiumHQ.DTOs.EmailTriage.CreateEmailTriageStatusRequest.BringBackDays, if nothing has changed its status by then. Switched off, the days and target are cleared."
          },
          "bringBackDays": {
            "maximum": 365,
            "minimum": 1,
            "type": "integer",
            "description": "With SodiumHQ.DTOs.EmailTriage.CreateEmailTriageStatusRequest.BringBackEnabled: the default number of days before the conversation is brought back (1 to 365)",
            "format": "int32",
            "nullable": true
          },
          "bringBackStatusCode": {
            "maxLength": 100,
            "type": "string",
            "description": "With SodiumHQ.DTOs.EmailTriage.CreateEmailTriageStatusRequest.BringBackEnabled: the default status to bring the conversation back to, an active status that\ndoes not mean Done and is not this one",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create an email triage status"
      },
      "CreateEngagementRequest": {
        "required": [
          "clientCode",
          "date",
          "type"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the client this engagement belongs to"
          },
          "date": {
            "type": "string",
            "description": "Date of the engagement",
            "format": "date"
          },
          "type": {
            "$ref": "#/components/schemas/EngagementType"
          },
          "recipientFirstName": {
            "type": "string",
            "description": "First name of the recipient for this engagement",
            "nullable": true
          },
          "recipientLastName": {
            "type": "string",
            "description": "Last name of the recipient for this engagement",
            "nullable": true
          },
          "recipientEmail": {
            "type": "string",
            "description": "Email address of the recipient for this engagement",
            "nullable": true
          },
          "requestDdMandate": {
            "type": "boolean",
            "description": "Per-proposal override for the \"set up Direct Debit\" acceptance step.\nNull leaves the practice default (from proposal settings) in effect for this proposal.",
            "nullable": true
          },
          "requestAmlOnboarding": {
            "type": "boolean",
            "description": "Per-proposal override for the identity-verification (AML) acceptance step.\nNull leaves the practice default (from proposal settings) in effect for this proposal.",
            "nullable": true
          },
          "showPricingSummary": {
            "type": "boolean",
            "description": "Per-proposal override for showing the pricing summary panel on the acceptance page.\nNull leaves the practice default (from proposal settings) in effect for this proposal.",
            "nullable": true
          },
          "excludedDataFormCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the forms configured in proposal settings that this proposal opts out of.\nEmpty leaves every configured form in effect for this proposal.",
            "nullable": true
          },
          "proposalTemplateCode": {
            "type": "string",
            "description": "Code of the template to use for the proposal document",
            "nullable": true
          },
          "lofETemplateCode": {
            "type": "string",
            "description": "Code of the template to use for the letter of engagement (LofE) document",
            "nullable": true
          },
          "clientBillableServiceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of ClientBillableService codes to include in this engagement.\n            \nIMPORTANT: The system will create a historical snapshot of each ClientBillableService at its current state.\nThis snapshot is stored as JSON and preserves the service details even if the original\nClientBillableService is later modified or deleted.\n            \nThe snapshot includes: name, description, price, billing frequency, start/end dates, and the\nClientBillableServiceCode for reference.\n            \nExample: [\"CBS001\", \"CBS002\", \"CBS003\"]",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new engagement"
      },
      "CreateExternalFolderRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 255,
            "minLength": 1,
            "pattern": "^(?![.\\s])(?:[^\\\\/:*?\"<>|\\x00-\\x1F]*[^.\\s\\\\/:*?\"<>|\\x00-\\x1F])$",
            "type": "string",
            "description": "Name for the new folder. Cannot contain characters that storage providers reject\n(\\ / : * ? \" < > |) and cannot start or end with a space or a full stop."
          },
          "parentFolderId": {
            "type": "string",
            "description": "Platform-specific id of the folder to create the new folder inside. Omit to create it\nat the top level of the client's mapped folder.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a new folder in the client's external storage provider."
      },
      "CreateHmrcAgentCredentialRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "What the practice calls this set. Unique within the practice."
          },
          "agentReferenceNumber": {
            "maxLength": 20,
            "type": "string",
            "description": "Agent Reference Number (ARN) from the Agent Services Account.",
            "nullable": true
          },
          "saAgentCode": {
            "maxLength": 20,
            "type": "string",
            "description": "Self Assessment agent code (e.g. A12345).",
            "nullable": true
          },
          "payeAgentCode": {
            "maxLength": 20,
            "type": "string",
            "description": "PAYE/CIS agent code (e.g. 123/A12345).",
            "nullable": true
          },
          "ctAgentCode": {
            "maxLength": 20,
            "type": "string",
            "description": "Corporation Tax agent code.",
            "nullable": true
          },
          "contactFirstName": {
            "maxLength": 50,
            "type": "string",
            "description": "First name of the agent contact.",
            "nullable": true
          },
          "contactLastName": {
            "maxLength": 50,
            "type": "string",
            "description": "Last name of the agent contact.",
            "nullable": true
          },
          "contactEmail": {
            "maxLength": 150,
            "type": "string",
            "description": "Email of the agent contact.",
            "format": "email",
            "nullable": true
          },
          "govGatewayUserId": {
            "maxLength": 30,
            "type": "string",
            "description": "Government Gateway user ID.",
            "nullable": true
          },
          "govGatewayPassword": {
            "maxLength": 100,
            "type": "string",
            "description": "Government Gateway password (write-only). Set to update, empty string to clear, null to leave unchanged.",
            "nullable": true
          },
          "useTestGateway": {
            "type": "boolean",
            "description": "CIS Manager files this set's returns with HMRC's test gateway, not the live one."
          },
          "testInLive": {
            "type": "boolean",
            "description": "CIS Manager flags this set's live returns as tests. Ignored (stored false) with the test gateway."
          }
        },
        "additionalProperties": false,
        "description": "Adds a credential set. The practice's first set becomes the default."
      },
      "CreateMailboxDraftRequest": {
        "required": [
          "htmlBody"
        ],
        "type": "object",
        "properties": {
          "subject": {
            "type": "string",
            "description": "Subject line",
            "nullable": true
          },
          "plainTextBody": {
            "type": "string",
            "description": "Plain text body (optional fallback)",
            "nullable": true
          },
          "toRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "To recipients",
            "nullable": true
          },
          "ccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "CC recipients",
            "nullable": true
          },
          "bccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "BCC recipients",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAttachmentDto"
            },
            "description": "Attachments to include. Null or empty = no attachments.",
            "nullable": true
          },
          "htmlBody": {
            "minLength": 1,
            "type": "string",
            "description": "HTML body of the draft. Redeclared from the email service contract so it is cleaned as the request is read."
          },
          "practiceDocumentCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of practice documents (tenant document library) to attach. Resolved to file\ncontent server-side, so the browser never round-trips the document bytes.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a mailbox draft, extending the email service contract with practice\ndocument attachments resolved server-side by code (same pattern as sending a new email)."
      },
      "CreateMailboxReplyDraftRequest": {
        "required": [
          "htmlBody"
        ],
        "type": "object",
        "properties": {
          "plainTextBody": {
            "type": "string",
            "description": "Plain text body (optional fallback)",
            "nullable": true
          },
          "replyAll": {
            "type": "boolean",
            "description": "Whether to reply to all recipients (default: false = reply to sender only)"
          },
          "toRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "Override To recipients. Null = use provider default (original sender for reply, all for reply-all).\nEmpty list = explicitly no To recipients.",
            "nullable": true
          },
          "ccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "Override CC recipients. Null = use provider default.\nEmpty list = explicitly no CC recipients (useful for removing CC on reply-all).",
            "nullable": true
          },
          "bccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "BCC recipients. Null or empty = no BCC (providers never auto-populate BCC).",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAttachmentDto"
            },
            "description": "Attachments to include in the reply. Null or empty = no attachments.",
            "nullable": true
          },
          "quoteOriginal": {
            "type": "boolean",
            "description": "Whether a sent reply carries the email it answers below the caller's text (\"On ... wrote:\" and\nthe original, quoted), as Outlook and Gmail do. Off by default: the reply is the caller's text\nalone. A reply draft is never quoted."
          },
          "htmlBody": {
            "minLength": 1,
            "type": "string",
            "description": "HTML body of the reply. Redeclared from the email service contract so it is cleaned as the request is read."
          },
          "practiceDocumentCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of practice documents (tenant document library) to attach. Resolved to file\ncontent server-side, so the browser never round-trips the document bytes.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a reply to a mailbox message as a draft, extending the email service reply\ncontract with practice document attachments resolved server-side by code. Nothing is sent."
      },
      "CreateMailboxShareRuleRequest": {
        "required": [
          "kind",
          "value"
        ],
        "type": "object",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/MailboxShareRuleKind"
          },
          "value": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "An email address (Address), a domain without the @ (Domain), a conversation id\n(Conversation), a folder UniqueId (Folder) or a message UniqueId (Message). Addresses and\ndomains are stored lowercased."
          },
          "isExclusion": {
            "type": "boolean",
            "description": "False (the default) shares what the rule matches; true hides it from everyone but the\nowner. Not required, so older clients that send no flag keep creating shares."
          }
        },
        "additionalProperties": false,
        "description": "Request to add a share or exclusion rule to a mailbox configuration. Creating a rule that\nalready exists returns the existing rule; creating one whose kind and value exist with the\nother flag flips that rule (latest intent wins)."
      },
      "CreateMeetingNoteRequest": {
        "required": [
          "medium",
          "startTime",
          "title"
        ],
        "type": "object",
        "properties": {
          "title": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "Short plain-text title, e.g. \"Missed call from Jane Smith\""
          },
          "startTime": {
            "type": "string",
            "description": "When the meeting started, ISO 8601 with a time zone (Z or an offset); stored as UTC. A time with no zone is\nrejected rather than guessed at.",
            "format": "date-time"
          },
          "endTime": {
            "type": "string",
            "description": "When the meeting ended, as for StartTime. Not before StartTime.",
            "format": "date-time",
            "nullable": true
          },
          "medium": {
            "$ref": "#/components/schemas/MeetingMedium"
          },
          "summary": {
            "type": "string",
            "description": "Summary, HTML. A value with no HTML tags is taken as plain text: encoded, with line breaks kept.",
            "nullable": true
          },
          "content": {
            "type": "string",
            "description": "The full content, usually a transcript, HTML. A value with no HTML tags is taken as plain text: encoded, with\nline breaks kept.",
            "nullable": true
          },
          "taskItemCode": {
            "type": "string",
            "description": "The code of the client's task the meeting was about. Must be one of the client's tasks.",
            "nullable": true
          },
          "contactCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the client contacts who attended. Each must be linked to the client. Replaces the list on update.",
            "nullable": true
          },
          "userCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the staff who attended. Replaces the list on update.",
            "nullable": true
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MeetingNoteLinkDto"
            },
            "description": "Links to outside resources, such as the recording, in display order. Replaces the list on update.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to record a meeting or call with a client. A note with only a title, start time and medium is valid (a\nmissed call has no summary or content)."
      },
      "CreateMessagingTemplateRequest": {
        "required": [
          "body",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "What staff pick it by; unique in the practice"
          },
          "body": {
            "maxLength": 1600,
            "minLength": 1,
            "type": "string",
            "description": "The text with Liquid tokens, at most 1,600 characters (the SMS limit). A token that does not parse\nis a 400 on body."
          }
        },
        "additionalProperties": false,
        "description": "A new practice text template"
      },
      "CreateMtdBroughtForwardLossRequest": {
        "required": [
          "businessId",
          "lossAmount",
          "typeOfLoss"
        ],
        "type": "object",
        "properties": {
          "businessId": {
            "maxLength": 20,
            "minLength": 1,
            "type": "string",
            "description": "HMRC's identifier for the income source the loss belongs to."
          },
          "typeOfLoss": {
            "$ref": "#/components/schemas/HmrcLossType"
          },
          "lossAmount": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "The amount carried forward, as a positive figure.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Records a loss the client carries forward from a year before Making Tax Digital (to 2025-26).\n            \nNot idempotent at HMRC: a repeated request either creates a second loss or is refused as a\nduplicate, so this is never retried automatically."
      },
      "CreateMtdLossClaimRequest": {
        "required": [
          "businessId",
          "taxYearClaimedFor",
          "typeOfClaim",
          "typeOfLoss"
        ],
        "type": "object",
        "properties": {
          "businessId": {
            "maxLength": 20,
            "minLength": 1,
            "type": "string",
            "description": "HMRC's identifier for the income source the claim is made against."
          },
          "taxYearClaimedFor": {
            "maxLength": 7,
            "minLength": 1,
            "type": "string",
            "description": "The tax year the claim is made for, e.g. 2025-26."
          },
          "typeOfLoss": {
            "$ref": "#/components/schemas/HmrcLossType"
          },
          "typeOfClaim": {
            "$ref": "#/components/schemas/HmrcLossClaimType"
          }
        },
        "additionalProperties": false,
        "description": "Claims a loss (to 2025-26). HMRC accept nothing until the income source's accounting period has\nended, and which claim types are legal depends on the type of loss."
      },
      "CreateNotClientEmailRuleRequest": {
        "required": [
          "value"
        ],
        "type": "object",
        "properties": {
          "value": {
            "maxLength": 255,
            "minLength": 0,
            "type": "string",
            "description": "An email address (e.g. \"noreply@hmrc.gov.uk\") or a domain (e.g. \"hmrc.gov.uk\")"
          }
        },
        "additionalProperties": false,
        "description": "Request to mark an email address or domain as not a client. Stored lower-cased. A free-mail domain\n(gmail.com and the like) is refused, and so is a value that is already one of a client's email rules.\nMarking a value that is already marked returns the existing marker."
      },
      "CreateOnboardingReportRequest": {
        "required": [
          "levelId"
        ],
        "type": "object",
        "properties": {
          "levelId": {
            "minLength": 1,
            "type": "string",
            "description": "The onboarding level ID to use."
          },
          "sendEmail": {
            "type": "boolean",
            "description": "Whether to send the onboarding email to the contact."
          },
          "mailTemplateId": {
            "type": "string",
            "description": "The mail template ID to use when sending the email. Required when SendEmail is true.",
            "nullable": true
          },
          "replaceExisting": {
            "type": "boolean",
            "description": "Cancel the contact's existing onboarding report before creating this one. Used to retry a\nreport that is stuck (for example after the AML platform ran out of credits)."
          }
        },
        "additionalProperties": false,
        "description": "Request to create an onboarding report for a contact in the AML platform."
      },
      "CreateOnboardingTaskTemplateRequest": {
        "required": [
          "billableServiceCode"
        ],
        "type": "object",
        "properties": {
          "billableServiceCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the billable service this template belongs to"
          },
          "name": {
            "type": "string",
            "description": "The name of the onboarding task",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The description of the onboarding task",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "dueDateOffsetDays": {
            "type": "integer",
            "description": "Days after service start date for the task due date",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day stamped onto the start date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day stamped onto the due date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Code of the user to assign tasks to (only used if AssignmentType is SpecificUser)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "Code of the team to assign tasks to (optional, independent of AssignmentType)",
            "nullable": true
          },
          "workflowCode": {
            "type": "string",
            "description": "Code of the workflow template to apply to generated tasks",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "Code of the category to apply to generated tasks",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this onboarding task template",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this template is active"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new onboarding task template"
      },
      "CreateOutboundWebhookRequest": {
        "required": [
          "eventTypes",
          "isEnabled",
          "name",
          "payloadMode",
          "url"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "What the practice calls it. 1 to 100 characters."
          },
          "url": {
            "maxLength": 2048,
            "minLength": 1,
            "type": "string",
            "description": "Where events are posted: an absolute `https` URL of at most 2048 characters, with no user info."
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The event types it wants, from the catalogue (`GET /metadata/outbound-webhook-event-types`), or `*`\nalone for every event, including ones added later."
          },
          "payloadMode": {
            "$ref": "#/components/schemas/OutboundWebhookPayloadMode"
          },
          "isEnabled": {
            "type": "boolean",
            "description": "Whether events are sent to it. Switching it off cancels deliveries still waiting to be sent."
          }
        },
        "additionalProperties": false,
        "description": "A new webhook as the practice creates it (docs/features/Webhooks/PLAN.md D7)."
      },
      "CreatePipelineOnboardingTaskTemplateRequest": {
        "required": [
          "pipelineCode"
        ],
        "type": "object",
        "properties": {
          "pipelineCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the pipeline this template belongs to"
          },
          "name": {
            "type": "string",
            "description": "The name of the intake task",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The description of the intake task",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "dueDateOffsetDays": {
            "type": "integer",
            "description": "Days after the card's start date for the task due date",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day stamped onto the start date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day stamped onto the due date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Code of the user to assign tasks to (only used if AssignmentType is SpecificUser)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "Code of the team to assign tasks to (optional, independent of AssignmentType)",
            "nullable": true
          },
          "workflowCode": {
            "type": "string",
            "description": "Code of the workflow template to apply to generated tasks",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "Code of the category to apply to generated tasks",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this intake task template",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this template is active"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new pipeline intake task template"
      },
      "CreatePipelineRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the pipeline"
          },
          "description": {
            "type": "string",
            "description": "The description of the pipeline",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "Indicates whether this pipeline is archived (inactive)"
          },
          "defaultManagedByUserCode": {
            "type": "string",
            "description": "The code of the user who is the default manager for this pipeline",
            "nullable": true
          },
          "showKanbanBoard": {
            "type": "boolean",
            "description": "Whether this pipeline should appear on the Boards kanban view"
          },
          "trackDealValue": {
            "type": "boolean",
            "description": "Whether cards on this pipeline carry a deal value and likelihood, with full and weighted totals on the board"
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PipelineStageDto"
            },
            "description": "User-defined stages for this pipeline",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new sales pipeline"
      },
      "CreateProfessionalClearanceRequestItemRequest": {
        "type": "object",
        "properties": {
          "request": {
            "type": "string",
            "description": "The request text",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying the requests",
            "format": "int32"
          },
          "global": {
            "type": "boolean",
            "description": "If true, this item will be included for all clients regardless of the services they have"
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a professional clearance request item"
      },
      "CreateRecurringTaskItemRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the recurring task",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The description of the recurring task",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Code of the user to assign tasks to (only used if AssignmentType is SpecificUser)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "Code of the team to assign tasks to (optional, independent of AssignmentType)",
            "nullable": true
          },
          "billableServiceCode": {
            "type": "string",
            "description": "Code of the billable service (only used if AssignmentType is ClientServiceManager, ClientServicePreparer or ClientServiceReviewer)",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Sort order for displaying recurring tasks",
            "format": "int32",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this recurring task is active and will generate new tasks"
          },
          "schedule": {
            "$ref": "#/components/schemas/ScheduleConfigDto"
          },
          "process": {
            "$ref": "#/components/schemas/ProcessConfigRequestDto"
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "categoryCode": {
            "type": "string",
            "description": "Code of the category to apply to generated tasks (optional)",
            "nullable": true
          },
          "clientAssociationType": {
            "$ref": "#/components/schemas/ClientAssociationType"
          },
          "vatReportingPeriod": {
            "$ref": "#/components/schemas/VatReportingPeriod"
          },
          "taskNameTemplate": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional template for naming tasks created from this recurring task.\nSupports {{ token }} placeholders (e.g. \"VAT Return - {{ ClientName }} - {{ Quarter }} {{ Year }}\").\nWhen null or empty, tasks use the recurring task's Name.\nAvailable tokens can be retrieved from the GET /metadata/task-name-tokens endpoint.\nUnrecognised tokens are left as-is in generated task names.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new recurring task template"
      },
      "CreateRevenueRangeRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The display name of the revenue range (e.g., \"£30k - £70k\")",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying revenue ranges",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a revenue range"
      },
      "CreateRiskAssessmentRequest": {
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string",
            "description": "Optional questionnaire template ID. If provided, a questionnaire based on this template is attached to the risk assessment.",
            "nullable": true
          },
          "sourceRiskAssessmentId": {
            "type": "string",
            "description": "Optional id of an earlier risk assessment for the same client. If provided, the new assessment starts with every\nanswer copied from it where the questions match.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a new risk assessment in the AML platform."
      },
      "CreateRoleRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name of the role. Must be unique within the practice and cannot use a\nbuilt-in role name (Admin, Standard User, Viewer)."
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional description of what this role is for",
            "nullable": true
          },
          "permissions": {
            "type": "object",
            "properties": {
              "Tasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Users": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Clients": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Contacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientContacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Reports": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Settings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ApiKeys": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Roles": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ServicePackages": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "RecurringTasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Workflows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ThirdPartyConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ContentBlocks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDetails": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DesignThemes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Templates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Engagements": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CustomFields": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Subscription": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientPortalSettings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DocumentRequests": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Billing": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientEmailRules": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Mailbox": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Teams": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DataForms": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "KanbanBoards": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBilling": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailBroadcasts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeTracking": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Pipelines": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "WorkingPatterns": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalIncomeTax": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalTaxReturn": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooksConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BookkeepingHealth": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CostRates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ProductAccounts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Messaging": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeOff": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailTriage": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "JobBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "OutboundWebhooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeOverrides": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              }
            },
            "additionalProperties": false,
            "description": "The capabilities to grant per entity. Capabilities are independent flags — include every\ncapability the role should have; \"Admin\" grants everything on that entity. Grants are capped\nat the capabilities the requesting user themselves holds on each entity: anything beyond\nthat is silently reduced, not rejected.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a custom role."
      },
      "CreateSavedClientFilterRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "User-friendly name for this saved filter (e.g., \"Active Limited Companies\", \"My Managed Clients\")"
          },
          "description": {
            "maxLength": 1000,
            "type": "string",
            "description": "Optional description providing more details about this filter's purpose",
            "nullable": true
          },
          "includeInMenu": {
            "type": "boolean",
            "description": "Whether this filter should be included in the current user's menu/quick access list.\nThis is a per-user preference — it does not affect other users of a shared filter."
          },
          "isShared": {
            "type": "boolean",
            "description": "Whether this filter is shared with all users in the tenant. Shared filters are\nvisible (read-only) to everyone; only the owner can modify or delete them."
          },
          "managerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by manager code(s)",
            "nullable": true
          },
          "partnerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by partner code(s)",
            "nullable": true
          },
          "associateCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by associate code(s)",
            "nullable": true
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientStatus"
            },
            "description": "Filter by client status(es)",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "Filter by client type(s)",
            "nullable": true
          },
          "serviceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by billable service code(s)",
            "nullable": true
          },
          "packageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by service package code(s)",
            "nullable": true
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by team code(s)",
            "nullable": true
          },
          "serviceStageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by service stage composite codes (format: \"serviceCode:stageCode\")",
            "nullable": true
          },
          "serviceStatuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceStatus"
            },
            "description": "Service statuses a client's service must have: the chosen service's, or any service's when no service or stage is filtered. Null means any status.",
            "nullable": true
          },
          "customFieldFilters": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by custom field composite values (format: \"fieldCode:value\", or \"fieldCode:\" for blank)",
            "nullable": true
          },
          "keyDateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "keyDateRange": {
            "$ref": "#/components/schemas/PresetDateRange"
          },
          "keyDateFrom": {
            "type": "string",
            "description": "Start of the key date window. Only set when KeyDateRange is CustomDateRange.",
            "format": "date",
            "nullable": true
          },
          "keyDateTo": {
            "type": "string",
            "description": "End of the key date window. Only set when KeyDateRange is CustomDateRange.",
            "format": "date",
            "nullable": true
          },
          "defaultSortKeyDateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "defaultSortField": {
            "$ref": "#/components/schemas/ClientSortField"
          },
          "defaultSortDesc": {
            "type": "boolean",
            "description": "Sort in descending order (true) or ascending order (false)",
            "nullable": true
          },
          "iconName": {
            "maxLength": 100,
            "type": "string",
            "description": "Optional Lucide icon name for visual identification (e.g., \"Calendar\", \"Users\", \"Star\")",
            "nullable": true
          },
          "color": {
            "maxLength": 7,
            "type": "string",
            "description": "Optional hex color for visual identification (e.g., \"#FF5733\")",
            "nullable": true
          },
          "columnConfigJson": {
            "type": "string",
            "description": "Optional JSON column configuration for the saved view.\nWhen set, overrides the user's default client column preferences.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request model for creating a new saved client filter"
      },
      "CreateSavedTaskFilterRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "User-friendly name for this saved filter (e.g., \"My Overdue Tasks\", \"Client ABC Tasks\")"
          },
          "description": {
            "maxLength": 1000,
            "type": "string",
            "description": "Optional description providing more details about this filter's purpose",
            "nullable": true
          },
          "includeInMenu": {
            "type": "boolean",
            "description": "Whether this filter should be included in the current user's menu/quick access list.\nThis is a per-user preference — it does not affect other users of a shared filter."
          },
          "isShared": {
            "type": "boolean",
            "description": "Whether this filter is shared with all users in the tenant. Shared filters are\nvisible (read-only) to everyone; only the owner can modify or delete them."
          },
          "dateRange": {
            "$ref": "#/components/schemas/PresetDateRange"
          },
          "startDate": {
            "type": "string",
            "description": "Custom start date (only used when DateRange = CustomDateRange)",
            "format": "date",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "Custom end date (only used when DateRange = CustomDateRange)",
            "format": "date",
            "nullable": true
          },
          "dateBasis": {
            "$ref": "#/components/schemas/TaskDateBasis"
          },
          "clientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by client code(s)",
            "nullable": true
          },
          "userCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by user code(s)",
            "nullable": true
          },
          "recurringTaskCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by recurring task code(s)",
            "nullable": true
          },
          "categoryCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by category code(s)",
            "nullable": true
          },
          "serviceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by billable service code(s)",
            "nullable": true
          },
          "serviceStageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by billable service stage. Composite \"serviceCode:stageCode\" values, since a stage\ncode is only unique within its parent service.",
            "nullable": true
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by team code(s)",
            "nullable": true
          },
          "clientManagerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the primary client's manager (user codes). Clientless tasks never match.",
            "nullable": true
          },
          "clientPartnerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the primary client's partner (user codes). Clientless tasks never match.",
            "nullable": true
          },
          "clientAssociateCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the primary client's associate (user codes). Clientless tasks never match.",
            "nullable": true
          },
          "servicePreparerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the Preparer in force on the task's service (user codes). Tasks without one never match.",
            "nullable": true
          },
          "serviceReviewerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the Reviewer in force on the task's service (user codes). Tasks without one never match.",
            "nullable": true
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskItemStatus"
            },
            "description": "Filter by task status(es)",
            "nullable": true
          },
          "isOverdue": {
            "type": "boolean",
            "description": "Filter to only overdue tasks",
            "nullable": true
          },
          "isUnassigned": {
            "type": "boolean",
            "description": "Include tasks with no assigned user. Can be combined with UserCodes to show\ntasks that are either unassigned OR assigned to specific users.",
            "nullable": true
          },
          "isAutomationDisabled": {
            "type": "boolean",
            "description": "Filter by the automation switch: true for tasks with automation off, false for those with\nit on, null for both. Task previews are excluded whenever this is set.",
            "nullable": true
          },
          "includeProjected": {
            "type": "boolean",
            "description": "Include projected (virtual) tasks in the results"
          },
          "includeWorkflowSteps": {
            "type": "boolean",
            "description": "Include workflow steps in the results (Agenda mode)"
          },
          "defaultSortField": {
            "$ref": "#/components/schemas/TaskItemSortField"
          },
          "defaultSortDesc": {
            "type": "boolean",
            "description": "Sort in descending order (true) or ascending order (false)",
            "nullable": true
          },
          "iconName": {
            "maxLength": 100,
            "type": "string",
            "description": "Optional Lucide icon name for visual identification (e.g., \"Calendar\", \"Users\", \"Star\")",
            "nullable": true
          },
          "color": {
            "maxLength": 7,
            "type": "string",
            "description": "Optional hex color for visual identification (e.g., \"#FF5733\")",
            "nullable": true
          },
          "columnConfigJson": {
            "type": "string",
            "description": "Optional JSON column configuration for the saved view.\nWhen set, overrides the user's default task column preferences.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request model for creating a new saved task filter"
      },
      "CreateServiceCategoryRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name of the service category"
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying service categories",
            "format": "int32"
          },
          "color": {
            "maxLength": 20,
            "type": "string",
            "description": "The color associated with this service category",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a service category"
      },
      "CreateServicePackageItemRequest": {
        "required": [
          "billableServiceCode"
        ],
        "type": "object",
        "properties": {
          "billableServiceCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the billable service to include"
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "overridePricing": {
            "type": "boolean",
            "description": "Whether to override the standard pricing from the billable service"
          },
          "price": {
            "type": "number",
            "description": "The custom price to use when OverridePricing is true",
            "format": "double",
            "nullable": true
          },
          "pricingAnswers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Pre-answered pricing factors (key = factor description, value = selected option name)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for a service to include in a service package"
      },
      "CreateServicePackageRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the service package"
          },
          "description": {
            "type": "string",
            "description": "Description of what this package includes",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "Whether this package is archived (inactive)"
          },
          "usePackagePricing": {
            "type": "boolean",
            "description": "Whether this package uses a single package-level price instead of summing individual item prices"
          },
          "packagePrice": {
            "type": "number",
            "description": "The flat price for the entire package. Required when UsePackagePricing is true.",
            "format": "double",
            "nullable": true
          },
          "packageBillingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "packageSetupFee": {
            "type": "number",
            "description": "Optional one-off setup fee for the package, billed once when the package is first invoiced.\nOnly used when UsePackagePricing is true. Null means no setup fee.",
            "format": "double",
            "nullable": true
          },
          "proposalContentCode": {
            "type": "string",
            "description": "The code of the proposal content block. Only used when UsePackagePricing is true.\nWhen set, overrides the individual content blocks defined on each service in the package.\nWhen null, proposals fall back to each service's own proposal content block.",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreateServicePackageItemRequest"
            },
            "description": "The services to include in this package",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new service package"
      },
      "CreateTaskCategoryRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The display name of the task category",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying task categories",
            "format": "int32"
          },
          "color": {
            "type": "string",
            "description": "The color associated with this task category",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a task category"
      },
      "CreateTaskItemNoteRequest": {
        "required": [
          "date",
          "noteFromUserCode",
          "text"
        ],
        "type": "object",
        "properties": {
          "text": {
            "minLength": 1,
            "type": "string",
            "description": "The text content of the note"
          },
          "date": {
            "type": "string",
            "description": "The date/time the note was created",
            "format": "date-time"
          },
          "noteFromUserCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the user who authored this note"
          },
          "pinnedLevel": {
            "type": "integer",
            "description": "The pinned level: 0 not pinned, 1 top of the notes section, 2 top of the client or task page, 3 the dashboard",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new task item note"
      },
      "CreateTaskItemRequest": {
        "required": [
          "dueDate",
          "name",
          "startDate",
          "status"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the task"
          },
          "description": {
            "type": "string",
            "description": "The description of the task",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "startDate": {
            "type": "string",
            "description": "When the task starts",
            "format": "date"
          },
          "dueDate": {
            "type": "string",
            "description": "When the task is due",
            "format": "date"
          },
          "statutoryDueDate": {
            "type": "string",
            "description": "The statutory due date for compliance tasks (if applicable)",
            "format": "date",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "Time of day on the start date. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day on the due date. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "clientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the clients this task is associated with (optional)",
            "nullable": true
          },
          "primaryClientCode": {
            "type": "string",
            "description": "The code of the primary client for this task (optional)",
            "nullable": true
          },
          "assignedUserCode": {
            "type": "string",
            "description": "The code of the user to assign the task to (optional)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "The code of the team to assign the task to (optional)",
            "nullable": true
          },
          "clientBillableServiceCode": {
            "type": "string",
            "description": "The code of the client billable service this task relates to (optional)",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "The code of the category for this task (optional)",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this task",
            "nullable": true
          },
          "isAutomationDisabled": {
            "type": "boolean",
            "description": "Automation switch. On create, null lets Sodium decide: a task starting today or in the past\nlands with automation off, so creating it never runs workflow steps as a side effect. An\nexplicit value wins over that rule - true is off whatever the dates, false is on.\nOn update, null leaves it unchanged; a different value switches automation, which on the way\non runs any steps that are ready.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request model for creating a new task"
      },
      "CreateTaskTemplateRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "The name of the task template"
          },
          "description": {
            "type": "string",
            "description": "The description applied to tasks created from this template",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "billableServiceCode": {
            "type": "string",
            "description": "Code of the billable service this template is optionally associated with",
            "nullable": true
          },
          "dueDateOffsetDays": {
            "type": "integer",
            "description": "Days after the creation date for the default task due date",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day stamped onto the start date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day stamped onto the due date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Code of the user to assign tasks to (only used if AssignmentType is SpecificUser)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "Code of the team to assign tasks to (optional, independent of AssignmentType)",
            "nullable": true
          },
          "workflowCode": {
            "type": "string",
            "description": "Code of the workflow template to apply to created tasks",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "Code of the category to apply to created tasks",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this task template",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this template is active (inactive templates are hidden when creating tasks)"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new one-off task template"
      },
      "CreateTeamRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "The display name of the team"
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional description of the team's purpose",
            "nullable": true
          },
          "iconName": {
            "maxLength": 100,
            "type": "string",
            "description": "Optional Lucide icon name for visual identification",
            "nullable": true
          },
          "color": {
            "maxLength": 7,
            "type": "string",
            "description": "Optional hex color for visual identification",
            "nullable": true
          },
          "canBeAssignedToTasks": {
            "type": "boolean",
            "description": "Whether this team can be assigned to tasks"
          },
          "canBeAssignedToClients": {
            "type": "boolean",
            "description": "Whether this team can be assigned to clients"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a team"
      },
      "CreateTenantHolidayRequest": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "The date of the holiday, or its first day when it runs over several (format: yyyy-MM-dd)",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "The last day of a holiday that runs over several days (inclusive). Empty for a single day",
            "format": "date",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Name of the holiday (e.g., \"Company Anniversary\", \"Office Closure\")",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a tenant-specific holiday"
      },
      "CreateTenantUserRequest": {
        "required": [
          "email"
        ],
        "type": "object",
        "properties": {
          "roleType": {
            "$ref": "#/components/schemas/RoleType"
          },
          "roleCode": {
            "type": "string",
            "description": "The code of the custom role (only used if RoleType is Custom)",
            "nullable": true
          },
          "systemRoleType": {
            "$ref": "#/components/schemas/SystemRole"
          },
          "isClientManager": {
            "type": "boolean",
            "description": "Whether the user is a client manager within the tenant"
          },
          "isPartner": {
            "type": "boolean",
            "description": "Whether the user is a partner within the tenant"
          },
          "isAssociate": {
            "type": "boolean",
            "description": "Whether the user is an associate within the tenant"
          },
          "isRestrictedToTeamClients": {
            "type": "boolean",
            "description": "Whether the user can only see clients belonging to their teams"
          },
          "isRestrictedToAssignedClients": {
            "type": "boolean",
            "description": "Whether the user can only see clients where they are Manager, Partner, or Associate"
          },
          "isRestrictedToOwnTime": {
            "type": "boolean",
            "description": "Whether the user can only see and edit their own time entries"
          },
          "isPaidForTrackedTime": {
            "type": "boolean",
            "description": "Whether the practice pays this user for their tracked time (contract basis) —\nputs them on the Unpaid Time pay surfaces"
          },
          "workingPatternCode": {
            "type": "string",
            "description": "The code of the working pattern this user is on — how many hours they're expected to\nlog each day. Null puts them on the practice's default pattern.",
            "nullable": true
          },
          "email": {
            "minLength": 1,
            "type": "string",
            "format": "email"
          },
          "firstName": {
            "type": "string",
            "description": "The user's first name (required for creating new users)",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "description": "The user's last name (required for creating new users)",
            "nullable": true
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Optional list of team codes to assign the user to on creation",
            "nullable": true
          },
          "hourlyRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Charge-out rate per hour, seeding the user's first rate entry. Null gives the user no\nrate of their own, so the practice default applies. After creation, rates are managed\nvia the user's rates endpoints.",
            "format": "double",
            "nullable": true
          },
          "costRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Internal cost rate per hour, seeding the user's first rate entry.\nRequires the Cost Rates permission.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for creating a user within a tenant. Inherits update fields and adds email/name for creation."
      },
      "CreateTextBroadcastRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "savedViewCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The code of a saved client view whose filter selects which clients to include. The view's criteria are resolved\nwhen recipients are resolved, so later changes to the view are picked up until the text is sent. Mutually\nexclusive with Filter.",
            "nullable": true,
            "example": "active-limited-companies"
          },
          "filter": {
            "$ref": "#/components/schemas/EmailBroadcastFilterDto"
          },
          "excludedClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Client codes to exclude from the filter results",
            "nullable": true
          },
          "additionalClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hand-picked client codes to add on top of the filter results",
            "nullable": true
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "The client contact types texted at each client, on their mobiles. A draft needs at least one; a summary with none\nworks out only the client and preference counts.",
            "nullable": true
          },
          "sendOncePerNumber": {
            "type": "boolean",
            "description": "When true (the default), a number held by contacts at several clients is texted once, with the first client's\ntokens; the other clients are skipped",
            "example": true
          },
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "What the bulk text is called in the list, the client notes and Messages",
            "example": "January self assessment reminder"
          },
          "routing": {
            "$ref": "#/components/schemas/MessagingRequestTextRouting"
          },
          "templateCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The practice text template whose body is the SMS text. Mutually exclusive with Body.",
            "nullable": true,
            "example": "self-assessment-reminder"
          },
          "body": {
            "maxLength": 1600,
            "type": "string",
            "description": "The SMS text with Liquid tokens ({{ Client.Name }}, {{ Contact.FirstName }}, {{ Practice.Name }}, {{ Url }} …),\nrendered for each client and recipient. Mutually exclusive with TemplateCode.",
            "nullable": true,
            "example": "Hi {{ Contact.FirstName }}, your tax return for {{ Client.Name }} is due on 31 January."
          },
          "whatsAppTemplateId": {
            "type": "string",
            "description": "The approved WhatsApp template sent where the routing chooses WhatsApp: required with KnownNumbers or\nTryWhatsAppFirst, and must be omitted with SmsOnly. Refused when it has no approved live version.",
            "format": "uuid",
            "nullable": true
          },
          "contentVariables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "What fills each of the WhatsApp template's placeholders, by placeholder (\"1\", \"2\"…): a token expression such as\n{{ Contact.FirstName }}, rendered per recipient. Every placeholder of the template's approved version must be\nfilled, and no other. Must be omitted with SmsOnly routing.",
            "nullable": true,
            "example": {
              "1": "{{ Contact.FirstName }}",
              "2": "{{ Client.Name }}"
            }
          }
        },
        "additionalProperties": false,
        "description": "Request to create a draft bulk text (docs/features/BulkTextMessages/PLAN.md D2, D4, D8). The SMS text is a practice\ntext template or inline text, not both. The clients, and who at each is texted (at least one contact type), are\nthe audience request's: a saved view or an inline filter (not both), plus hand-picked additions, less exclusions."
      },
      "CreateThirdPartyConnectionRequest": {
        "required": [
          "platform"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name for the connection",
            "nullable": true
          },
          "redirectUrl": {
            "type": "string",
            "description": "URL to redirect the user to after OAuth flow completes. \nIf you use [code] in the url then we'll replace it with the Code of this ThirdPartyConnection.\nThis solves the problem of not knowing the code at creation time.",
            "nullable": true
          },
          "platform": {
            "minLength": 1,
            "type": "string",
            "description": "The platform identifier (e.g., \"Xero\", \"FreeAgent\", \"Xama\"). For document storage platforms, connecting again continues\nthe practice's existing connection for that platform and returns it with a fresh authorisation URL, so documents and client folders stay attached."
          },
          "apiKey": {
            "type": "string",
            "description": "API key for ApiKey-authenticated platforms (e.g., Socket personal access token)",
            "nullable": true
          },
          "oAuthClientId": {
            "type": "string",
            "description": "OAuth client ID for OAuthClientCredentials flow (e.g., Xama OAuth ID)",
            "nullable": true
          },
          "oAuthClientSecret": {
            "type": "string",
            "description": "OAuth client secret for OAuthClientCredentials flow (e.g., Xama OAuth Secret)",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "description": "External organization/client ID for OAuthClientCredentials flow (e.g., Xama Client ID)",
            "nullable": true
          },
          "useExtendedScopes": {
            "type": "boolean",
            "description": "Request the platform's extended scopes as well as its base scopes. Only meaningful for platforms\nwhere `hasExtendedScopes` is true on the platform metadata; ignored otherwise. The stored\ntokens carry this grant, so the level can only be chosen again when reconnecting."
          },
          "importFrom": {
            "type": "string",
            "description": "Meeting notes platforms only: nothing created before this date is imported. Defaults to today.",
            "format": "date",
            "nullable": true
          },
          "options": {
            "$ref": "#/components/schemas/ConnectionOptionsDto"
          }
        },
        "additionalProperties": false,
        "description": "Request for creating a new ThirdPartyConnection"
      },
      "CreateTimeEntryRequest": {
        "required": [
          "entryDate"
        ],
        "type": "object",
        "properties": {
          "userCode": {
            "type": "string",
            "description": "The code of the team member who did the work. Defaults to the calling user when omitted.",
            "nullable": true
          },
          "entryDate": {
            "type": "string",
            "description": "The day the work was done (format: yyyy-MM-dd)",
            "format": "date"
          },
          "durationMinutes": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "How long the work took, in minutes",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "When the work started (UTC) — optional, set by timer-logged entries",
            "format": "date-time",
            "nullable": true
          },
          "endTime": {
            "type": "string",
            "description": "When the work ended (UTC) — optional, set by timer-logged entries",
            "format": "date-time",
            "nullable": true
          },
          "description": {
            "maxLength": 1000,
            "type": "string",
            "description": "What the time was spent on",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The code of the client the time relates to (optional unless the practice requires linking)",
            "nullable": true
          },
          "taskItemCode": {
            "type": "string",
            "description": "The code of the task the time relates to (optional unless the practice requires linking)",
            "nullable": true
          },
          "serviceCode": {
            "type": "string",
            "description": "The code of the client service to attribute the time to directly, instead of\nvia a task. Requires ClientCode (service codes are client-scoped) and cannot\nbe combined with TaskItemCode — a task already determines the service.",
            "nullable": true
          },
          "stageCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The service stage the time was logged in, among the stages of the entry's service. Left out, it\ndefaults to the stage the task last moved its service to, else the service's current stage",
            "nullable": true
          },
          "workflowGroupNumber": {
            "type": "integer",
            "description": "The group number of the workflow step the time relates to (optional; requires\nTaskItemCode and WorkflowStepNumber)",
            "format": "int32",
            "nullable": true
          },
          "workflowStepNumber": {
            "type": "integer",
            "description": "The step number of the workflow step the time relates to (optional; requires\nTaskItemCode and WorkflowGroupNumber)",
            "format": "int32",
            "nullable": true
          },
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimerBlockDto"
            },
            "description": "The work blocks the entry was logged from, for timer-logged entries. When\nprovided, StartTime, EndTime and DurationMinutes are derived from the blocks\n(span start, span end, summed working time) and any supplied values are ignored.\nEach block needs either a start and end time or a duration in minutes.",
            "nullable": true
          },
          "isBillable": {
            "type": "boolean",
            "description": "Whether this time can be billed to the client"
          },
          "hourlyRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Charge-out rate per hour. When omitted, defaults to the rate in force on the entry date, billable\nor not: non-billable time is valued too, against the job's fee budget (ClientJobBudgets R4).",
            "format": "double",
            "nullable": true
          },
          "externalEventUid": {
            "maxLength": 500,
            "type": "string",
            "description": "The external calendar meeting the time was logged from (the occurrence's UID from the\ncalendar events list), so logging the same meeting twice can be spotted. Fixed once set.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to create a time entry"
      },
      "CreateUserNoteRequest": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "The note content. Optional, so a note can be created empty and filled in later.",
            "nullable": true
          },
          "isRichText": {
            "type": "boolean",
            "description": "Whether SodiumHQ.DTOs.UserNote.CreateUserNoteRequest.Text is HTML from the rich-text editor rather than plain text.\nNew notes are rich text unless the caller says otherwise."
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating one of the caller's own notes"
      },
      "CreateWorkflowRequest": {
        "required": [
          "groups",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The name of the workflow"
          },
          "description": {
            "type": "string",
            "description": "Optional description explaining the workflow's purpose",
            "nullable": true
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowGroupDto"
            },
            "description": "The workflow groups containing steps"
          }
        },
        "additionalProperties": false,
        "description": "Request to create a new workflow"
      },
      "CreateWorkingPatternRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name of the pattern, e.g. \"Full time\" or \"Part time (Mon/Wed/Fri)\""
          },
          "isDefault": {
            "type": "boolean",
            "description": "Make this the tenant's default pattern, clearing the flag from the previous default"
          },
          "expectedMinutesMonday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Monday (7.5 hours = 450)",
            "format": "int32"
          },
          "expectedMinutesTuesday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Tuesday",
            "format": "int32"
          },
          "expectedMinutesWednesday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Wednesday",
            "format": "int32"
          },
          "expectedMinutesThursday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Thursday",
            "format": "int32"
          },
          "expectedMinutesFriday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Friday",
            "format": "int32"
          },
          "expectedMinutesSaturday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Saturday",
            "format": "int32"
          },
          "expectedMinutesSunday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Sunday",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Request to create a working pattern. Days left unset expect no time, which is how a\npattern says \"this member doesn't work that day\"."
      },
      "CreateWriteOffReasonRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name, e.g. \"Quoted fixed fee\""
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position in the reason picker",
            "format": "int32"
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the reason is offered for new write-offs (default true)"
          }
        },
        "additionalProperties": false,
        "description": "Request to create a write-off reason"
      },
      "CreatedClientBillingLineItemDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this line item",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "clientBillableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "servicePackage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "description": {
            "type": "string",
            "description": "The invoice line description",
            "nullable": true
          },
          "quantity": {
            "type": "number",
            "description": "The quantity",
            "format": "double"
          },
          "unitPrice": {
            "type": "number",
            "description": "Snapshot of the effective price at generation",
            "format": "double"
          },
          "vatRate": {
            "$ref": "#/components/schemas/VatRate"
          },
          "accountingCode": {
            "type": "string",
            "description": "The accounting/nominal code",
            "nullable": true
          },
          "periodStart": {
            "type": "string",
            "description": "Start of the service period covered",
            "format": "date-time",
            "nullable": true
          },
          "periodEnd": {
            "type": "string",
            "description": "End of the service period covered",
            "format": "date-time",
            "nullable": true
          },
          "generatedDate": {
            "type": "string",
            "description": "When the line item was generated",
            "format": "date-time"
          },
          "billingDate": {
            "type": "string",
            "description": "Target invoice date",
            "format": "date-time"
          },
          "status": {
            "$ref": "#/components/schemas/ClientBillingLineItemStatus"
          },
          "invoiceSubmissionCode": {
            "type": "string",
            "description": "The invoice submission code this was bundled into (null until invoiced)",
            "nullable": true
          },
          "timeEntryCount": {
            "type": "integer",
            "description": "How many time entries were billed on this line. Non-zero means the line is derived from\ntime: its quantity and unit price are locked, and it is undone by deleting it.",
            "format": "int32"
          },
          "scheduleItemCode": {
            "type": "string",
            "description": "The billing schedule item this line was promoted from. Null for manual and time-derived\nlines. A schedule-promoted line is bound to the service or package it was generated from.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the line item was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the line item was last updated",
            "format": "date-time",
            "nullable": true
          },
          "invoiceError": {
            "type": "string",
            "description": "Why the invoice push failed, when InvoiceNow was requested and the line was created but not\ninvoiced. The line is then approved and on a failed submission, which is retried from the\nclient's invoice submissions. Null otherwise.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The line item a create returned, with the outcome of invoicing it when the request asked for\nthat. A line that was invoiced comes back with status Invoiced."
      },
      "CryptoassetDisposal": {
        "type": "object",
        "properties": {
          "numberOfDisposals": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "assetDescription": {
            "type": "string",
            "nullable": true
          },
          "tokenName": {
            "type": "string",
            "nullable": true
          },
          "acquisitionDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "disposalDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "disposalProceeds": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "allowableCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsWithBadr": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsBeforeLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "losses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "claimOrElectionCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "amountOfNetGain": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountOfNetLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "rttTaxPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CsvColumnMappingDto": {
        "type": "object",
        "properties": {
          "csvHeader": {
            "type": "string",
            "description": "The CSV column header name exactly as it appears in the file.\nMust match the header row in the CSV (case-sensitive).",
            "nullable": true,
            "example": "Company Number"
          },
          "targetField": {
            "$ref": "#/components/schemas/ClientCsvTargetField"
          },
          "customFieldCode": {
            "type": "string",
            "description": "The code of the client custom field this column maps to. Null when SodiumHQ.DTOs.CsvImport.CsvColumnMappingDto.TargetField is set.",
            "nullable": true,
            "example": "annual-turnover"
          }
        },
        "additionalProperties": false,
        "description": "Represents a single column mapping from a CSV header to a client field.\nUsed in column mapping configurations to specify how CSV data maps to client records."
      },
      "CsvExportFilterDto": {
        "type": "object",
        "properties": {
          "managerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by their assigned manager's code(s).",
            "nullable": true,
            "example": [
              "MGR001"
            ]
          },
          "partnerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by their assigned partner's code(s).",
            "nullable": true,
            "example": [
              "PTR001"
            ]
          },
          "associateCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by their assigned associate's code(s).",
            "nullable": true,
            "example": [
              "ASC001"
            ]
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientStatus"
            },
            "description": "Filter clients by status(es).\nValues: Active, Inactive, Prospect, LostProspect",
            "nullable": true,
            "example": [
              "Active"
            ]
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "Filter clients by their organization type(s).\nValues: Individual, Partnership, LLP, PrivateLimitedCompany, PublicLimitedCompany, Charity, Club, Trust, PublicSectorBody, OverseasCompany",
            "nullable": true,
            "example": [
              "PrivateLimitedCompany"
            ]
          },
          "serviceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by billable service code(s) they have assigned.",
            "nullable": true,
            "example": [
              "SVC001"
            ]
          },
          "serviceStatuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceStatus"
            },
            "description": "Service statuses a client's service must have: the chosen service's, or any service's when no service is filtered. Null means any status.",
            "nullable": true,
            "example": [
              "Active"
            ]
          },
          "search": {
            "type": "string",
            "description": "Search across client code, name and internal reference.\nMinimum 3 characters.",
            "nullable": true,
            "example": "acme"
          }
        },
        "additionalProperties": false,
        "description": "Filter criteria for selecting which clients to export.\nMatches the same filters available on the client list endpoint."
      },
      "CsvExportJobDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying this export job.\nUse this code to poll the export's status endpoint.",
            "nullable": true,
            "example": "exp-abc123"
          },
          "status": {
            "$ref": "#/components/schemas/ImportJobStatus"
          },
          "totalItems": {
            "type": "integer",
            "description": "Total number of records (clients or contacts) to export.\nSet when the export job starts processing.",
            "format": "int32",
            "example": 150
          },
          "processedItems": {
            "type": "integer",
            "description": "Number of records that have been written to the CSV so far.\nCompare with TotalItems to calculate progress percentage.",
            "format": "int32",
            "example": 75
          },
          "downloadUrl": {
            "type": "string",
            "description": "URL to download the generated CSV file.\nOnly available when Status is Completed.\nThis is a time-limited SAS URL that expires after the export job's expiry date.",
            "nullable": true,
            "example": "https://storage.blob.core.windows.net/csv-exports/tenant-123/exp-abc123.csv?sv=2021-06-08&se=2024-01-16T10:30:00Z..."
          },
          "startedDate": {
            "type": "string",
            "description": "When the job started processing (UTC).\nNull if the job hasn't started yet (status is Queued).",
            "format": "date-time",
            "nullable": true,
            "example": "2024-01-15T10:30:00Z"
          },
          "completedDate": {
            "type": "string",
            "description": "When the job completed processing (UTC).\nNull if the job hasn't completed yet (status is Queued or InProgress).\nSet for both successful completion and failure.",
            "format": "date-time",
            "nullable": true,
            "example": "2024-01-15T10:31:45Z"
          },
          "createdDate": {
            "type": "string",
            "description": "When the export job was created (UTC).",
            "format": "date-time",
            "example": "2024-01-15T10:30:00Z"
          }
        },
        "additionalProperties": false,
        "description": "Represents the current status and progress of a CSV export job.\nReturned when starting an export or polling for status.\nUse this to track progress and obtain the download URL when complete."
      },
      "CsvExportRequestDto": {
        "type": "object",
        "properties": {
          "mappingCode": {
            "type": "string",
            "description": "Code of an existing saved mapping to use for column headers.\nUse GET /clients/import/csv/mappings to list available mappings.\nMutually exclusive with ColumnMappings - provide one or the other.\nIf neither is provided, all fields are exported with enum names as headers.",
            "nullable": true,
            "example": "limited-company-clients"
          },
          "columnMappings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CsvColumnMappingDto"
            },
            "description": "Inline column mappings for the export.\nEach mapping specifies which client field maps to which CSV header.\nMutually exclusive with MappingCode - provide one or the other.\nIf neither is provided, all fields are exported with enum names as headers.",
            "nullable": true
          },
          "includeHeaders": {
            "type": "boolean",
            "description": "Whether to include a header row in the CSV output.\nDefault: true",
            "example": true
          },
          "savedFilterCode": {
            "type": "string",
            "description": "Code of a saved view whose clients to export. The file holds every client the view matches,\nwith all of its filters applied. Mutually exclusive with Filter - provide one or the other.\nOnly a view the user owns or that is shared with them can be exported.",
            "nullable": true,
            "example": "my-active-clients"
          },
          "filter": {
            "$ref": "#/components/schemas/CsvExportFilterDto"
          }
        },
        "additionalProperties": false,
        "description": "Request to start a CSV export of clients.\nSpecify column mappings and optional filter criteria to control the export output."
      },
      "CsvImportJobDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying this import job.\nUse this code to poll for status via GET /{code}.",
            "nullable": true,
            "example": "csv-abc123"
          },
          "status": {
            "$ref": "#/components/schemas/ImportJobStatus"
          },
          "fileName": {
            "type": "string",
            "description": "Original filename of the uploaded CSV file.",
            "nullable": true,
            "example": "clients-export-2024.csv"
          },
          "totalItems": {
            "type": "integer",
            "description": "Total number of data rows to import (excluding header row).\nMay be null if the job hasn't started processing yet.",
            "format": "int32",
            "nullable": true,
            "example": 150
          },
          "processedItems": {
            "type": "integer",
            "description": "Number of rows that have been processed so far.\nCompare with totalItems to calculate progress percentage.",
            "format": "int32",
            "example": 75
          },
          "createdCount": {
            "type": "integer",
            "description": "Number of new client records created during import.\nOnly incremented when importMode is CreateOnly or CreateAndUpdate.",
            "format": "int32",
            "example": 50
          },
          "updatedCount": {
            "type": "integer",
            "description": "Number of existing client records updated during import.\nOnly incremented when a match is found and importMode is UpdateOnly or CreateAndUpdate.",
            "format": "int32",
            "example": 20
          },
          "skippedCount": {
            "type": "integer",
            "description": "Number of rows skipped during import.\nReasons for skipping:\n- importMode is CreateOnly and a matching client already exists\n- importMode is UpdateOnly and no matching client was found\n- Row is missing required fields (e.g., Name)",
            "format": "int32",
            "example": 3
          },
          "errorCount": {
            "type": "integer",
            "description": "Number of rows that failed with errors during import.\nErrors may include validation failures or database errors.\nThe import continues processing remaining rows after an error.",
            "format": "int32",
            "example": 2
          },
          "warningCount": {
            "type": "integer",
            "description": "Number of rows that imported but had one or more custom field values skipped (partial imports).\nThese rows are included in the non-imported report, distinguished by their reason.",
            "format": "int32",
            "example": 3
          },
          "startedDate": {
            "type": "string",
            "description": "When the job started processing (UTC).\nNull if the job hasn't started yet (status is Queued).",
            "format": "date-time",
            "nullable": true,
            "example": "2024-01-15T10:30:00Z"
          },
          "completedDate": {
            "type": "string",
            "description": "When the job completed processing (UTC).\nNull if the job hasn't completed yet (status is Queued or Processing).\nSet for both successful completion and failure.",
            "format": "date-time",
            "nullable": true,
            "example": "2024-01-15T10:31:45Z"
          },
          "createdDate": {
            "type": "string",
            "description": "When the import job was created (UTC).\nThis is when the CSV file was uploaded.",
            "format": "date-time",
            "example": "2024-01-15T10:30:00Z"
          },
          "notImportedDownloadUrl": {
            "type": "string",
            "description": "URL to download a CSV containing rows that were not imported (errors and skips).\nOnly available when status is Completed and there were errors or skipped rows.\nThe CSV has the same columns as the source file plus Row and Reason columns,\nso it can be re-imported directly after fixing issues.\nThis is a time-limited SAS URL that expires after 60 minutes.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents the current status and progress of a CSV import job.\nReturned when starting an import or polling for status.\nUse this to track progress and final results of the import operation."
      },
      "CsvImportMatchField": {
        "enum": [
          "Code",
          "Name",
          "CompanyNumber",
          "InternalReference",
          "NiNumber"
        ],
        "type": "string",
        "example": "Code"
      },
      "CsvImportMode": {
        "enum": [
          "CreateOnly",
          "UpdateOnly",
          "CreateAndUpdate"
        ],
        "type": "string",
        "example": "CreateOnly"
      },
      "CsvMappingDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying this mapping.\nUse this code in the mappingCode parameter when uploading or confirming an import/export.\nPreset codes: 'limited-company-clients', 'individual-clients'.",
            "nullable": true,
            "example": "limited-company-clients"
          },
          "name": {
            "type": "string",
            "description": "Human-readable display name for this mapping.",
            "nullable": true,
            "example": "Limited Company"
          },
          "columnMappings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CsvColumnMappingDto"
            },
            "description": "The column mappings that define how CSV headers map to target fields.\nEach entry specifies a CSV header name and the corresponding client field.",
            "nullable": true
          },
          "matchField": {
            "$ref": "#/components/schemas/CsvImportMatchField"
          },
          "isPreset": {
            "type": "boolean",
            "description": "True if this is a preset mapping available to all tenants.\nPreset mappings cannot be modified or deleted.\nFalse for tenant-specific custom mappings.",
            "example": true
          },
          "mappingType": {
            "$ref": "#/components/schemas/CsvMappingType"
          },
          "createdDate": {
            "type": "string",
            "description": "When this mapping was created (UTC).",
            "format": "date-time",
            "example": "2024-01-15T10:30:00Z"
          },
          "updatedDate": {
            "type": "string",
            "description": "When this mapping was last updated (UTC). Null if never updated.",
            "format": "date-time",
            "nullable": true,
            "example": "2024-01-20T14:45:00Z"
          }
        },
        "additionalProperties": false,
        "description": "Represents a saved CSV mapping configuration.\nMappings define how CSV columns map to client fields and can be reused across imports and exports.\nPreset mappings are available to all tenants; tenant mappings are private."
      },
      "CsvMappingDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CsvMappingDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CsvMappingSortField": {
        "enum": [
          "Name",
          "CreatedDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "CsvMappingType": {
        "enum": [
          "Client"
        ],
        "type": "string",
        "example": "Client"
      },
      "CsvUploadResponseDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying this import job.\nUse this code to confirm and start the import via PUT /{code},\nor to check status via GET /{code}.",
            "nullable": true,
            "example": "csv-abc123"
          },
          "hasHeaderRow": {
            "type": "boolean",
            "description": "Whether the first row was treated as column headers.\nIf hasHeaderRow was explicitly provided in the request, this reflects that value.\nIf not provided, this shows the auto-detected result based on the first row content.",
            "example": true
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of column headers detected from the CSV file.\nIf hasHeaderRow was true, these are from the first row.\nIf hasHeaderRow was false, these are auto-generated (Column1, Column2, etc.).",
            "nullable": true,
            "example": [
              "Company Name",
              "Company Number",
              "VAT Number",
              "Email"
            ]
          },
          "totalRows": {
            "type": "integer",
            "description": "Total number of data rows in the CSV file (excluding the header row if present).\nThis is the number of rows that will be processed during import.",
            "format": "int32",
            "example": 150
          },
          "previewRows": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "description": "Preview of the first few rows from the CSV file.\nEach row is a dictionary mapping header names to cell values.\nUse this to verify the data looks correct before confirming the import.\nTypically includes up to 5 preview rows.",
            "nullable": true
          },
          "suggestedMappings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CsvColumnMappingDto"
            },
            "description": "Auto-suggested column mappings based on header name matching.\nThe system attempts to match CSV headers to known target fields using fuzzy matching.\nReview and adjust these mappings as needed when confirming the import.\nOnly includes mappings for headers that could be matched to target fields.",
            "nullable": true
          },
          "allowedTargetFields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientCsvTargetField"
            },
            "description": "Target fields that apply to this import's kind. Null means every target is available\n(client imports); contact imports return the contact-relevant subset.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response from uploading a CSV file with showPreview=true.\nContains a preview of the CSV data and auto-suggested column mappings.\nUse the code to call PUT /{code} to confirm mapping and start the import."
      },
      "CumulativeDisallowableExpenses": {
        "type": "object",
        "properties": {
          "costOfGoodsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "paymentsToSubcontractorsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "wagesAndStaffCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "carVanTravelExpensesDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "premisesRunningCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "maintenanceCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adminCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "businessEntertainmentCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "advertisingCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "interestOnBankOtherLoansDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "financeChargesDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "irrecoverableDebtsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "professionalFeesDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "depreciationDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherExpensesDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CumulativeExpenses": {
        "type": "object",
        "properties": {
          "costOfGoods": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "paymentsToSubcontractors": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "wagesAndStaffCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "carVanTravelExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "premisesRunningCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "maintenanceCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adminCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "businessEntertainmentCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "advertisingCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "interestOnBankOtherLoans": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "financeCharges": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "irrecoverableDebts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "professionalFees": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "depreciation": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "consolidatedExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CumulativeIncome": {
        "type": "object",
        "properties": {
          "turnover": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "other": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxTakenOffTradingIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CumulativePeriodDates": {
        "type": "object",
        "properties": {
          "periodStartDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "periodEndDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CurrencyMetadata": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "symbol": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CurrentAnnouncementDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying the announcement. Used as the per-browser dismissal key.",
            "nullable": true
          },
          "message": {
            "type": "string",
            "description": "The banner text shown on large screens.",
            "nullable": true
          },
          "messageShort": {
            "type": "string",
            "description": "Shorter banner text shown on small screens. Falls back to Message when null.",
            "nullable": true
          },
          "textColor": {
            "type": "string",
            "description": "Hex colour for the banner text (e.g. \"#FFFFFF\").",
            "nullable": true
          },
          "backgroundColor": {
            "type": "string",
            "description": "Hex colour for the banner background (e.g. \"#000000\").",
            "nullable": true
          },
          "linkUrl": {
            "type": "string",
            "description": "Optional link rendered after the message. Null means no link.",
            "nullable": true
          },
          "linkText": {
            "type": "string",
            "description": "Text for the optional link. Falls back to \"Find out more\" when null.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The currently active platform announcement banner, as shown to all users in the web app."
      },
      "CurrentUserResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The user's unique code",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The user's email address",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "description": "The user's first name",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "description": "The user's last name",
            "nullable": true
          },
          "fullName": {
            "type": "string",
            "description": "The user's full name",
            "nullable": true
          },
          "isEmailVerified": {
            "type": "boolean",
            "description": "Indicates whether the user's email address has been verified"
          },
          "isMfaCompleted": {
            "type": "boolean",
            "description": "Whether this sign-in session completed two-factor authentication. A session fact, not a\nuser setting: it lets the web app know whether requiring MFA on a practice will sign the\ncurrent user out."
          },
          "isSuperAdmin": {
            "type": "boolean",
            "description": "Indicates whether the user is a super admin"
          },
          "isSupportAgent": {
            "type": "boolean",
            "description": "Indicates whether the user is a support agent"
          },
          "avatar": {
            "type": "string",
            "description": "URL to the user's avatar image",
            "nullable": true
          },
          "authProvider": {
            "type": "string",
            "description": "The authentication provider type (Local, Auth0, Google, etc.)",
            "nullable": true
          },
          "utm": {
            "$ref": "#/components/schemas/UtmInfoDto"
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for the current authenticated user"
      },
      "CustomFieldDataType": {
        "enum": [
          "Text",
          "Number",
          "Date",
          "Boolean",
          "Select",
          "MultiSelect",
          "TextArea",
          "Address",
          "Email",
          "File",
          "Link",
          "RichText"
        ],
        "type": "string",
        "example": "Text"
      },
      "CustomFieldDefinitionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this custom field definition",
            "nullable": true
          },
          "label": {
            "type": "string",
            "description": "The display label shown to users for this field",
            "nullable": true
          },
          "entityType": {
            "$ref": "#/components/schemas/CustomFieldEntityType"
          },
          "dataType": {
            "$ref": "#/components/schemas/CustomFieldDataType"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The list of allowed options for Select and MultiSelect fields. Null for other data types.",
            "nullable": true
          },
          "clientTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "The types of clients this custom field is applicable to.\nAn empty list means the field is applicable to all client types.",
            "nullable": true
          },
          "billableServiceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the services a client must hold for this custom field to apply to them.\nAn empty list means the field applies regardless of the client's services.",
            "nullable": true
          },
          "isRequired": {
            "type": "boolean",
            "description": "Whether a value must be held for this field on every client the field applies to.\nA required field restricted by client type or by service is required only on the clients\nit applies to."
          },
          "maxLength": {
            "type": "integer",
            "description": "Maximum character length for Text and TextArea types. Null means no limit.",
            "format": "int32",
            "nullable": true
          },
          "lines": {
            "type": "integer",
            "description": "Number of visible text lines for TextArea type. Null defaults to 3.",
            "format": "int32",
            "nullable": true
          },
          "displayWidth": {
            "$ref": "#/components/schemas/FieldDisplayWidth"
          },
          "booleanDisplayMode": {
            "$ref": "#/components/schemas/BooleanDisplayMode"
          },
          "isFullRow": {
            "type": "boolean",
            "description": "Whether the field takes a whole row of its card on the record, rather than one column of it.\nDisplayWidth then applies within that row. Only for types whose metadata has HasFullRow."
          },
          "numberDecimalPlaces": {
            "type": "integer",
            "description": "Number fields only: decimal places the value renders with in templates (0 to 2). Null keeps the decimals as entered.",
            "format": "int32",
            "nullable": true
          },
          "numberThousandsSeparator": {
            "type": "boolean",
            "description": "Number fields only: whether the value renders in templates with a thousands separator."
          },
          "numberCurrencySymbol": {
            "type": "boolean",
            "description": "Number fields only: whether the value renders in templates with the practice currency symbol."
          },
          "customFieldGroupCode": {
            "type": "string",
            "description": "The code of the group this field belongs to",
            "nullable": true
          },
          "hasValues": {
            "type": "boolean",
            "description": "Whether any entities have values stored for this field. Only populated on detail responses.",
            "nullable": true
          },
          "workflowCount": {
            "type": "integer",
            "description": "How many workflows use this field as a group or step condition",
            "format": "int32"
          },
          "dataFormCount": {
            "type": "integer",
            "description": "How many data forms ask for this field or use it as a condition",
            "format": "int32"
          },
          "isArchived": {
            "type": "boolean",
            "description": "Whether this custom field definition has been archived"
          },
          "sortOrder": {
            "type": "integer",
            "description": "The display order of this field relative to other custom fields",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Defines a custom field that can be attached to entities such as clients.\nCustom fields allow tenants to capture additional data beyond the built-in fields."
      },
      "CustomFieldDefinitionDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomFieldDefinitionDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CustomFieldDefinitionSortField": {
        "enum": [
          "SortOrder",
          "Label"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "CustomFieldEntityType": {
        "enum": [
          "Client"
        ],
        "type": "string",
        "example": "Client"
      },
      "CustomFieldGroupDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this custom field group",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of this group",
            "nullable": true
          },
          "entityType": {
            "$ref": "#/components/schemas/CustomFieldEntityType"
          },
          "parentCustomFieldGroupCode": {
            "type": "string",
            "description": "The code of the parent group, or null if this is a root group",
            "nullable": true
          },
          "condition": {
            "$ref": "#/components/schemas/ConditionDto"
          },
          "sortOrder": {
            "type": "integer",
            "description": "The display order of this group relative to other groups",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A named group for organising custom field definitions.\nEach group renders as its own card on the entity detail page."
      },
      "CustomFieldGroupDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomFieldGroupDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CustomFieldGroupSortField": {
        "enum": [
          "SortOrder",
          "Name"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "CustomFieldValueDto": {
        "type": "object",
        "properties": {
          "fieldCode": {
            "type": "string",
            "description": "The code of the CustomFieldDefinition this value belongs to",
            "nullable": true
          },
          "value": {
            "type": "string",
            "description": "The value of the custom field, stored as a string regardless of data type.\nFor Boolean fields use \"true\"/\"false\", for Date fields use ISO 8601 format,\nfor MultiSelect fields use a comma-separated list of selected options.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A custom field value for a client. Use the custom field definitions endpoint\nto retrieve data types, labels, and allowed options for each field code."
      },
      "CustomTokenDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this custom token",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Human-readable display name for the token (e.g. \"Company Secretary\")",
            "nullable": true
          },
          "tokenIdentifier": {
            "type": "string",
            "description": "The token identifier used in templates (e.g. \"CompanySecretary\" for {{ Custom.CompanySecretary }}).\nAlphanumeric with underscores only.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional prompt text shown when filling in the token value",
            "nullable": true
          },
          "defaultValue": {
            "type": "string",
            "description": "Optional default value pre-populated in the token form",
            "nullable": true
          },
          "displayWidth": {
            "type": "string",
            "description": "Preset display width for the input. Null defaults to Full.",
            "nullable": true
          },
          "lines": {
            "type": "integer",
            "description": "Number of visible text lines. Null renders a single-line input, 2+ renders a textarea.",
            "format": "int32",
            "nullable": true
          },
          "isRichText": {
            "type": "boolean",
            "description": "When true and Lines >= 2, the input renders as a rich text editor instead of a plain textarea."
          },
          "isNumber": {
            "type": "boolean",
            "description": "When true the value is a number: the input takes a number and the token renders with the number format."
          },
          "numberDecimalPlaces": {
            "type": "integer",
            "description": "Number tokens only: decimal places the value renders with (0 to 2). Null keeps the decimals as entered.",
            "format": "int32",
            "nullable": true
          },
          "numberThousandsSeparator": {
            "type": "boolean",
            "description": "Number tokens only: whether the value renders with a thousands separator."
          },
          "numberCurrencySymbol": {
            "type": "boolean",
            "description": "Number tokens only: whether the value renders with the practice currency symbol."
          },
          "createdDate": {
            "type": "string",
            "description": "When the token was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the token was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A user-defined custom token for document templates"
      },
      "CustomTokenDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomTokenDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CustomTokenSortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "CustomerDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Platform-specific customer identifier (unique within the accounting platform)",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Customer/company name from the accounting platform",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "description": "Contact first name (if available from platform)",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "description": "Contact last name (if available from platform)",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "Primary email address for the customer",
            "nullable": true
          },
          "contactNumber": {
            "type": "string",
            "description": "Primary contact phone number",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the customer is active in the accounting platform"
          },
          "externalUrl": {
            "type": "string",
            "description": "Direct link to view the customer in the accounting platform",
            "nullable": true
          },
          "outstandingBalance": {
            "type": "number",
            "description": "Outstanding amount owed by the customer",
            "format": "double",
            "nullable": true
          },
          "overdueBalance": {
            "type": "number",
            "description": "Overdue amount owed by the customer",
            "format": "double",
            "nullable": true
          },
          "totalInvoiced": {
            "type": "number",
            "description": "Total amount invoiced to the customer (sum of all invoices)",
            "format": "double",
            "nullable": true
          },
          "platformData": {
            "type": "object",
            "additionalProperties": { },
            "description": "Platform-specific data that doesn't fit into the common model",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Customer data retrieved from third-party accounting platforms (Xero, QuickBooks, FreeAgent, etc.).\nRepresents a customer/client as stored in the accounting system, including contact details and financial balances.\nUsed for importing clients and syncing financial data."
      },
      "DashboardLinkDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier within the tenant",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "Where the link goes. Always an absolute http or https URL.",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "What to call the link. Null when it has no title, in which case show the URL.",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position in its list, lowest first",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a link on the dashboard"
      },
      "DashboardLinkScope": {
        "enum": [
          "Personal",
          "Practice"
        ],
        "type": "string",
        "example": "Personal"
      },
      "DashboardPinnedNoteDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this note, scoped to its client or task",
            "nullable": true
          },
          "text": {
            "type": "string",
            "description": "The note text",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "The date/time of the note",
            "format": "date-time"
          },
          "noteFromUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "entityType": {
            "$ref": "#/components/schemas/PinnedNoteEntityType"
          },
          "entity": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "stepName": {
            "type": "string",
            "description": "For notes on a workflow step, the step name. Null for task-level and client notes.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client or task note pinned to the dashboard, with the entity it belongs to so the\ndashboard can label it and open it"
      },
      "DataFormAnswerDto": {
        "type": "object",
        "properties": {
          "dataFormQuestionCode": {
            "type": "string",
            "description": "The code of the form question this answer belongs to",
            "nullable": true
          },
          "value": {
            "type": "string",
            "description": "The submitted answer value",
            "nullable": true
          },
          "reviewStatus": {
            "$ref": "#/components/schemas/DataFormAnswerReviewStatus"
          },
          "previousValue": {
            "type": "string",
            "description": "The client field's value at the time the form was submitted",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An individual answer to a form question"
      },
      "DataFormAnswerReviewStatus": {
        "enum": [
          "Pending",
          "Accepted",
          "Rejected"
        ],
        "type": "string",
        "example": "Pending"
      },
      "DataFormAnswerTokenDto": {
        "type": "object",
        "properties": {
          "tokenName": {
            "type": "string",
            "description": "The question's token name.",
            "nullable": true
          },
          "prompt": {
            "type": "string",
            "description": "The question, as the form asks it.",
            "nullable": true
          },
          "sectionTitle": {
            "type": "string",
            "description": "The title of the section the question is in.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One question's answer token, for the template editor's picker: insert it as `{{ Form.Answers.<tokenName> }}`."
      },
      "DataFormCategoryDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this form category",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the form category",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A grouping used to classify forms"
      },
      "DataFormCategoryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormCategoryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "DataFormCategorySortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "DataFormDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "introduction": {
            "type": "string",
            "description": "Introductory text shown at the top of the form when displayed to clients",
            "nullable": true
          },
          "category": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "status": {
            "$ref": "#/components/schemas/DataFormStatus"
          },
          "defaultMessage": {
            "type": "string",
            "description": "Default message included in the notification email when this form is sent to a client",
            "nullable": true
          },
          "exportDocumentTemplate": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "responseCount": {
            "type": "integer",
            "description": "Number of requests that have received a response. Used to warn when editing a form that has been used.",
            "format": "int32"
          },
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormSectionDto"
            },
            "description": "The sections and questions belonging to this form. Only populated on detail (GetByCode) responses.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A custom form definition (list view)"
      },
      "DataFormDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "DataFormExportDocumentRequest": {
        "required": [
          "editedHtml",
          "title"
        ],
        "type": "object",
        "properties": {
          "editedHtml": {
            "minLength": 1,
            "type": "string",
            "description": "The html from the editable-html route, as edited. It is not parsed as a template."
          },
          "title": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "The document's title; also its file name."
          },
          "documentCategoryCode": {
            "type": "string",
            "description": "Optional document category code.",
            "nullable": true
          },
          "visibleInClientPortal": {
            "type": "boolean",
            "description": "Whether the client sees the document in their portal. Off by default, as a form's uploaded files are."
          },
          "portalFolderPath": {
            "type": "string",
            "description": "Portal folder path for the document. When not specified, the practice's filing folder for form exports (Settings, Document Storage, Filing).\n\"/\" is the top of the portal.",
            "nullable": true
          },
          "storageFolderPath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for the document. When not specified, the practice's\nfiling folder for form exports. \"/\" is the client's folder itself.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The edited answers to save to the client's documents as a PDF."
      },
      "DataFormExportHtmlDto": {
        "type": "object",
        "properties": {
          "html": {
            "type": "string",
            "description": "The answers as HTML, in the form's export layout, with the client's data filled in.",
            "nullable": true
          },
          "designThemeCode": {
            "type": "string",
            "description": "Code of the design theme the PDF will use, so the editor can show its styling. Null when the practice has none.",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "The default title for the document, its PDF and an email: \"{form name} - {client name}\".",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A submitted form's answers laid out as an editable document."
      },
      "DataFormExportPdfRequest": {
        "required": [
          "editedHtml"
        ],
        "type": "object",
        "properties": {
          "editedHtml": {
            "minLength": 1,
            "type": "string",
            "description": "The html from the editable-html route, as edited. It is not parsed as a template."
          }
        },
        "additionalProperties": false,
        "description": "The edited answers to make a PDF of."
      },
      "DataFormPreviewDto": {
        "type": "object",
        "properties": {
          "dataFormName": {
            "type": "string",
            "nullable": true
          },
          "introduction": {
            "type": "string",
            "description": "Introductory text shown at the top of the form",
            "nullable": true
          },
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormPreviewSectionDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Preview of a form as the client would see it (sections + questions, no internal metadata)"
      },
      "DataFormPreviewQuestionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "prompt": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "dataType": {
            "$ref": "#/components/schemas/CustomFieldDataType"
          },
          "options": {
            "type": "string",
            "nullable": true
          },
          "maxLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "lines": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "displayWidth": {
            "$ref": "#/components/schemas/FieldDisplayWidth"
          },
          "booleanDisplayMode": {
            "$ref": "#/components/schemas/BooleanDisplayMode"
          },
          "isRequired": {
            "type": "boolean"
          },
          "sortOrder": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "DataFormPreviewSectionDto": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "nullable": true
          },
          "introduction": {
            "type": "string",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "format": "int32"
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormPreviewQuestionDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DataFormQuestionDto": {
        "required": [
          "prompt"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier for this question, used to key answers",
            "nullable": true
          },
          "tokenName": {
            "maxLength": 60,
            "type": "string",
            "description": "The name this question's answer goes by in a Form Answers template: {{ Form.Answers.<tokenName> }}.\nLetters, digits and underscore, starting with a letter, unique within the form. Blank is made from the prompt\non save. Changing it breaks templates that use it.",
            "nullable": true
          },
          "prompt": {
            "maxLength": 4000,
            "minLength": 1,
            "type": "string",
            "description": "The question text shown to the client"
          },
          "description": {
            "type": "string",
            "description": "An optional hint or clarification shown beneath the prompt",
            "nullable": true
          },
          "longDescription": {
            "type": "string",
            "description": "Optional rich-text long description shown as a tooltip on the form",
            "nullable": true
          },
          "questionType": {
            "$ref": "#/components/schemas/DataFormQuestionType"
          },
          "clientField": {
            "$ref": "#/components/schemas/ClientCsvTargetField"
          },
          "customFieldDefinition": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "dataType": {
            "$ref": "#/components/schemas/CustomFieldDataType"
          },
          "options": {
            "type": "string",
            "description": "JSON array of selectable options for Select/MultiSelect data types",
            "nullable": true
          },
          "maxLength": {
            "type": "integer",
            "description": "Maximum character length for Text and TextArea types",
            "format": "int32",
            "nullable": true
          },
          "lines": {
            "type": "integer",
            "description": "Number of visible text lines for TextArea type",
            "format": "int32",
            "nullable": true
          },
          "displayWidth": {
            "$ref": "#/components/schemas/FieldDisplayWidth"
          },
          "booleanDisplayMode": {
            "$ref": "#/components/schemas/BooleanDisplayMode"
          },
          "isRequired": {
            "type": "boolean",
            "description": "When true, the client must answer this question before submitting the form"
          },
          "sortOrder": {
            "type": "integer",
            "description": "The display order of this question relative to others in the section",
            "format": "int32"
          },
          "condition": {
            "$ref": "#/components/schemas/ConditionDto"
          }
        },
        "additionalProperties": false,
        "description": "A question within a form section"
      },
      "DataFormQuestionType": {
        "enum": [
          "ClientField",
          "CustomField",
          "DataFormSpecific"
        ],
        "type": "string",
        "example": "ClientField"
      },
      "DataFormRequestDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this form request",
            "nullable": true
          },
          "dataForm": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "status": {
            "$ref": "#/components/schemas/DataFormRequestStatus"
          },
          "submittedAt": {
            "type": "string",
            "description": "The date and time the client submitted their answers, if submitted",
            "format": "date-time",
            "nullable": true
          },
          "submittedByEmail": {
            "type": "string",
            "description": "Email address of the recipient who submitted (from magic link token).",
            "nullable": true
          },
          "notifyUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "autoAcceptData": {
            "type": "boolean",
            "description": "When true, submitted data is automatically accepted and copied to the client record without manual review"
          },
          "message": {
            "type": "string",
            "description": "A message from the sender explaining what the client needs to do",
            "nullable": true
          },
          "sentToEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The email addresses the form notification was sent to",
            "nullable": true
          },
          "sentAt": {
            "type": "string",
            "description": "When the notification email was sent",
            "format": "date-time",
            "nullable": true
          },
          "magicLinkToken": {
            "type": "string",
            "description": "The magic link token for this request. Only populated on detail responses for pending requests.",
            "format": "uuid",
            "nullable": true
          },
          "answers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormAnswerDto"
            },
            "description": "The submitted answers. Only populated on detail (GetByCode) responses.",
            "nullable": true
          },
          "form": {
            "$ref": "#/components/schemas/DataFormDto"
          },
          "pendingReviewCount": {
            "type": "integer",
            "description": "Number of answers still awaiting review (ReviewStatus = Pending)",
            "format": "int32"
          },
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "taskCategory": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "chase": {
            "$ref": "#/components/schemas/ChaseScheduleDto"
          },
          "createdDate": {
            "type": "string",
            "description": "The date and time this request was created (i.e. sent to the client)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "A form request sent to a client"
      },
      "DataFormRequestDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormRequestDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "DataFormRequestSortField": {
        "enum": [
          "CreatedDate",
          "Status",
          "DataFormName"
        ],
        "type": "string",
        "example": "CreatedDate"
      },
      "DataFormRequestStatus": {
        "enum": [
          "PendingResponse",
          "ResponseReceived",
          "Cancelled"
        ],
        "type": "string",
        "example": "PendingResponse"
      },
      "DataFormSectionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier for this section, used to match across saves",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "The display title of the section",
            "nullable": true
          },
          "introduction": {
            "type": "string",
            "description": "Introductory text shown to clients at the top of this section.",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The display order of this section relative to others in the form",
            "format": "int32"
          },
          "condition": {
            "$ref": "#/components/schemas/ConditionDto"
          },
          "clientTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "The types of clients this section is applicable to.\nAn empty list means the section is shown to all client types.",
            "nullable": true
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormQuestionDto"
            },
            "description": "The questions belonging to this section, in display order",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A section within a form"
      },
      "DataFormSortField": {
        "enum": [
          "Name",
          "Status"
        ],
        "type": "string",
        "example": "Name"
      },
      "DataFormStatus": {
        "enum": [
          "Draft",
          "Published",
          "Archived"
        ],
        "type": "string",
        "example": "Draft"
      },
      "DaysBeforeOrAfter": {
        "enum": [
          "OnActualDate",
          "DaysBefore",
          "DaysAfter"
        ],
        "type": "string",
        "example": "OnActualDate"
      },
      "DeadlineComplianceReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/DeadlineComplianceSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/DeadlineComplianceRowDtoPagedResult"
          },
          "upcomingDeadlines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UpcomingDeadlineBucketDto"
            },
            "description": "The forward-looking pipeline: open tasks with the chosen deadline, counted into\ndays-remaining buckets. Entity filters apply; the date window does not. Always all five\nbuckets, zero-filled, nearest first (overdue, 0-7, 8-14, 15-30, 31+).",
            "nullable": true
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC).",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Deadline Compliance report: which deadlines did we miss, and which are we about to?\nThe cohort is every non-Skipped task whose chosen deadline (due or statutory) fell in the\nwindow - so misses that are still open count, unlike a completion-anchored view."
      },
      "DeadlineComplianceRowDto": {
        "type": "object",
        "properties": {
          "groupKind": {
            "$ref": "#/components/schemas/ReportGroupKind"
          },
          "groupCode": {
            "type": "string",
            "description": "Entity code or month key (\"yyyy-MM\"). Null for null buckets.",
            "nullable": true
          },
          "groupName": {
            "type": "string",
            "description": "Display name for the group.",
            "nullable": true
          },
          "deadlineCount": {
            "type": "integer",
            "description": "Deadlines that fell in the window for this group.",
            "format": "int32"
          },
          "metCount": {
            "type": "integer",
            "description": "Deadlines met: task completed on or before the deadline.",
            "format": "int32"
          },
          "lateCount": {
            "type": "integer",
            "description": "Deadlines missed but recovered: task completed after the deadline.",
            "format": "int32"
          },
          "missedOpenCount": {
            "type": "integer",
            "description": "Deadlines missed and still open.",
            "format": "int32"
          },
          "pendingCount": {
            "type": "integer",
            "description": "Deadlines not yet reached, task still open - excluded from the compliance rate.",
            "format": "int32"
          },
          "compliancePct": {
            "type": "number",
            "description": "Met as a percentage of this group's decided deadlines. Null when nothing decided.",
            "format": "double",
            "nullable": true
          },
          "avgDaysLate": {
            "type": "number",
            "description": "Average days late across this group's misses. Null when there are no misses.",
            "format": "double",
            "nullable": true
          },
          "worstDaysLate": {
            "type": "integer",
            "description": "Days late of this group's worst miss. Null when there are no misses.",
            "format": "int32",
            "nullable": true
          },
          "worstTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "One row of the Deadline Compliance breakdown table."
      },
      "DeadlineComplianceRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DeadlineComplianceRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "DeadlineComplianceSummaryDto": {
        "type": "object",
        "properties": {
          "deadlineCount": {
            "type": "integer",
            "description": "Deadlines that fell in the window (Skipped tasks excluded).",
            "format": "int32"
          },
          "metCount": {
            "type": "integer",
            "description": "Deadlines met: task completed on or before the deadline.",
            "format": "int32"
          },
          "lateCount": {
            "type": "integer",
            "description": "Deadlines missed but recovered: task completed after the deadline.",
            "format": "int32"
          },
          "missedOpenCount": {
            "type": "integer",
            "description": "Deadlines missed and still open - the actionable misses.",
            "format": "int32"
          },
          "pendingCount": {
            "type": "integer",
            "description": "Deadlines in the window not yet reached, task still open - undecided, excluded from the\ncompliance rate. Only non-zero for windows that extend into the future.",
            "format": "int32"
          },
          "compliancePct": {
            "type": "number",
            "description": "Met as a percentage of decided deadlines (met + late + missed-open). Null when nothing\nhas been decided yet.",
            "format": "double",
            "nullable": true
          },
          "avgDaysLate": {
            "type": "number",
            "description": "Average days late across misses (late completions measured to completion, open misses to\ntoday). Null when there are no misses.",
            "format": "double",
            "nullable": true
          },
          "worstDaysLate": {
            "type": "integer",
            "description": "Days late of the worst miss. Null when there are no misses.",
            "format": "int32",
            "nullable": true
          },
          "worstTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "Headline KPIs for the Deadline Compliance report. Every cohort task lands in exactly one\nof Met / Late / MissedOpen / Pending."
      },
      "DeadlineReferenceType": {
        "enum": [
          "DueDate",
          "StartDate"
        ],
        "type": "string",
        "example": "DueDate"
      },
      "DesignThemeDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier for the design theme",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name for the theme (e.g., \"Professional Blue\", \"Corporate Standard\")",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether this is the default theme for the tenant. Only one theme per tenant should be marked as default."
          },
          "heading1": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "heading2": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "heading3": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "body": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "tableHeader": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "tableCell": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "logoUrl": {
            "type": "string",
            "description": "URL to the company logo image (used in document headers)",
            "nullable": true
          },
          "primaryColor": {
            "type": "string",
            "description": "Primary brand color in hex format (used for main headings and borders)",
            "nullable": true
          },
          "secondaryColor": {
            "type": "string",
            "description": "Secondary brand color in hex format (used for subheadings)",
            "nullable": true
          },
          "accentColor": {
            "type": "string",
            "description": "Accent color in hex format (used for highlights and calls to action)",
            "nullable": true
          },
          "backgroundColor": {
            "type": "string",
            "description": "Optional page background color in hex format. When null, no background-color is applied.",
            "nullable": true
          },
          "linkColor": {
            "type": "string",
            "description": "Optional link color in hex format. When null, links inherit default text color.",
            "nullable": true
          },
          "linkHoverColor": {
            "type": "string",
            "description": "Optional link hover color in hex format. When null, no hover color change.",
            "nullable": true
          },
          "primaryButton": {
            "$ref": "#/components/schemas/ButtonStyleDto"
          },
          "secondaryButton": {
            "$ref": "#/components/schemas/ButtonStyleDto"
          },
          "navBackgroundColor": {
            "type": "string",
            "description": "Navigation background color for the client portal (e.g., \"#1e293b\")",
            "nullable": true
          },
          "navTextColor": {
            "type": "string",
            "description": "Navigation text color for the client portal",
            "nullable": true
          },
          "navActiveBackgroundColor": {
            "type": "string",
            "description": "Active navigation item highlight color (supports rgba, e.g., \"rgba(255,255,255,0.15)\")",
            "nullable": true
          },
          "navActiveTextColor": {
            "type": "string",
            "description": "Active navigation item text color",
            "nullable": true
          },
          "cardBackgroundColor": {
            "type": "string",
            "description": "Card/panel background color in the content area",
            "nullable": true
          },
          "borderRadius": {
            "type": "integer",
            "description": "Global corner radius in pixels for cards, buttons, and inputs",
            "format": "int32",
            "nullable": true
          },
          "navFontSize": {
            "type": "number",
            "description": "Font size in points for the client portal navigation bar. Null falls back to body font size.",
            "format": "float",
            "nullable": true
          },
          "faviconUrl": {
            "type": "string",
            "description": "URL to a tenant-specific favicon for the client portal",
            "nullable": true
          },
          "pageMargins": {
            "$ref": "#/components/schemas/MarginsDto"
          },
          "headerTextContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "headerPageSelection": {
            "$ref": "#/components/schemas/PageSelection"
          },
          "footerContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "footerPageSelection": {
            "$ref": "#/components/schemas/PageSelection"
          },
          "pageNumberDisplay": {
            "$ref": "#/components/schemas/PageSelection"
          },
          "customCSS": {
            "type": "string",
            "description": "Additional custom CSS rules for advanced styling beyond the standard options",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When this theme was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When this theme was last updated",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Complete visual styling and branding configuration for generated documents (proposals, engagement letters, reports, etc.).\nDefines typography, colors, layout, headers, footers, and custom CSS to ensure consistent professional branding.\nDesign themes can be applied to document templates to control the appearance of generated PDFs and HTML documents."
      },
      "DesignThemeDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DesignThemeDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "DesignThemeSortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "DetectedAssigneeDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The assignee name as it appears in the file",
            "nullable": true
          },
          "rowCount": {
            "type": "integer",
            "description": "How many task rows carry this assignee",
            "format": "int32"
          },
          "suggestedUserCode": {
            "type": "string",
            "description": "The code of the tenant user whose name matches, to prefill the mapping; null when none",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A distinct assignee name found in a foreign task export"
      },
      "DetectedProgressValueDto": {
        "type": "object",
        "properties": {
          "value": {
            "type": "string",
            "description": "The progress value as it appears in the file",
            "nullable": true
          },
          "rowCount": {
            "type": "integer",
            "description": "How many task rows carry this value",
            "format": "int32"
          },
          "suggestedStatus": {
            "$ref": "#/components/schemas/TaskItemStatus"
          }
        },
        "additionalProperties": false,
        "description": "A distinct task progress value found in a foreign task export"
      },
      "DetectedServiceDto": {
        "type": "object",
        "properties": {
          "csvServiceName": {
            "type": "string",
            "description": "Display name of the detected service (e.g., \"SA100\", \"A/Cs\", \"A/Cs (2)\")",
            "nullable": true
          },
          "clientCount": {
            "type": "integer",
            "description": "Number of rows with a non-empty fee value for this service",
            "format": "int32"
          },
          "feeColumnIndex": {
            "type": "integer",
            "description": "The column index of the fee column for this service in the CSV.\nUsed to identify the correct column when headers are duplicated.",
            "format": "int32"
          },
          "includesPricing": {
            "type": "boolean",
            "description": "True when the file carries a price and billing frequency for this service.\nFalse for free-text-only services (e.g. Bright's \"Services\" summary column),\nwhich import unpriced and default to Annual billing."
          }
        },
        "additionalProperties": false,
        "description": "A service detected from the CSV headers during analysis"
      },
      "DirectDebitSettingsDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier for the settings",
            "nullable": true
          },
          "requestEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "Tenant-level configuration for direct debit request behavior and email settings.\nControls how direct debit requests are sent to clients."
      },
      "DirectorshipDividend": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "companyDirector": {
            "type": "boolean",
            "nullable": true
          },
          "closeCompany": {
            "type": "boolean",
            "nullable": true
          },
          "directorshipCeasedDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "companyName": {
            "type": "string",
            "nullable": true
          },
          "companyNumber": {
            "type": "string",
            "nullable": true
          },
          "shareholding": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "dividendReceived": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DividendGross": {
        "type": "object",
        "properties": {
          "customerReference": {
            "type": "string",
            "nullable": true
          },
          "grossAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DividendsIncome": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "foreignDividend": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignDividendItem"
            },
            "nullable": true
          },
          "dividendIncomeReceivedWhilstAbroad": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignDividendItem"
            },
            "nullable": true
          },
          "stockDividend": {
            "$ref": "#/components/schemas/DividendGross"
          },
          "redeemableShares": {
            "$ref": "#/components/schemas/DividendGross"
          },
          "bonusIssuesOfSecurities": {
            "$ref": "#/components/schemas/DividendGross"
          },
          "closeCompanyLoansWrittenOff": {
            "$ref": "#/components/schemas/DividendGross"
          }
        },
        "additionalProperties": false
      },
      "DocumentActionResultDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The document code, so the caller can match this result to the document it sent.",
            "nullable": true
          },
          "success": {
            "type": "boolean",
            "description": "Whether the action was applied to this document."
          },
          "error": {
            "type": "string",
            "description": "A message explaining why the action failed. Null when it succeeded.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of a bulk action on a single document within a batch."
      },
      "DocumentApprovalBatchDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for the batch",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "Code of the client the batch was sent to",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/DocumentApprovalBatchStatus"
          },
          "approvalMethod": {
            "$ref": "#/components/schemas/DocumentApprovalMethod"
          },
          "documentCount": {
            "type": "integer",
            "description": "How many documents the batch was sent with",
            "format": "int32"
          },
          "requestedByUserCode": {
            "type": "string",
            "description": "Code of the user who sent the batch for approval",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the batch was sent",
            "format": "date-time"
          },
          "chase": {
            "$ref": "#/components/schemas/ChaseScheduleDto"
          }
        },
        "additionalProperties": false,
        "description": "A group of client documents sent for approval together and decided with a single\napprove or reject action."
      },
      "DocumentApprovalBatchStatus": {
        "enum": [
          "Pending",
          "Approved",
          "Rejected",
          "Cancelled"
        ],
        "type": "string",
        "example": "Pending"
      },
      "DocumentApprovalExecutionStateDto": {
        "type": "object",
        "properties": {
          "documentCode": {
            "type": "string",
            "description": "The code of the first document sent for client approval.",
            "nullable": true
          },
          "documentCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of every document sent for client approval on this step. Null on steps executed\nbefore multi-document approvals existed — fall back to DocumentCode then.",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The client code the document belongs to.",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "description": "UTC timestamp of when the document was linked to this step.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Execution state for a DocumentApproval workflow step.\nContains information about the document sent for client approval.\nRead-only - written by the system during step execution, never edited by users."
      },
      "DocumentApprovalMethod": {
        "enum": [
          "Portal",
          "ESignature"
        ],
        "type": "string",
        "example": "Portal"
      },
      "DocumentApprovalRequestMode": {
        "enum": [
          "Individual",
          "Batch"
        ],
        "type": "string",
        "example": "Individual"
      },
      "DocumentApprovalStepConfigDto": {
        "type": "object",
        "properties": {
          "title": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional default title for the document.\nPre-fills the upload form so the user only needs to select the file.",
            "nullable": true
          },
          "summary": {
            "maxLength": 2000,
            "type": "string",
            "description": "Optional default summary for the document.\nPre-fills the upload form so the user only needs to select the file.",
            "nullable": true
          },
          "message": {
            "type": "string",
            "description": "Optional message for the client, shown in the approval email in place of the document's\ndescription. Ignored for e-signature approvals. May contain HTML and template tokens.",
            "nullable": true
          },
          "categoryCode": {
            "maxLength": 50,
            "type": "string",
            "description": "Optional default document category code.\nPre-fills the category dropdown on the upload form.",
            "nullable": true
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to send the approval request email to the client's business email\n(the email address on the client record)."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types to send the approval request email to.\nResolved at execution time from the task's associated client contacts.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to send the approval request email to.",
            "nullable": true
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for how often (in days) to chase this approval.\nWhen null, the tenant-level default is used for portal approvals; e-signature approvals\ndefault to no chasing (the signing platform sends its own reminders) unless a value is set.",
            "format": "int32",
            "nullable": true
          },
          "alsoSendText": {
            "type": "boolean",
            "description": "Also text each email recipient who is one of the client's contacts with a mobile, by SMS, with the same link as\ntheir email, worded by the practice's text wording for this kind of request. Ignored while the practice's\nmessaging is not Active."
          },
          "approvalMethod": {
            "$ref": "#/components/schemas/DocumentApprovalMethod"
          },
          "prepareOnPlatform": {
            "type": "boolean",
            "description": "E-signature only: create the bundle as a draft on the signing platform for the accountant to\nplace signature fields on, instead of sending it to the client straight away.\nIgnored when ApprovalMethod is Portal."
          },
          "documentTemplate": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "designThemeCode": {
            "maxLength": 50,
            "type": "string",
            "description": "Optional design theme override for PDF generation.\nWhen null, uses the template's default theme.",
            "nullable": true
          },
          "templateTokenValues": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Token values for template rendering, keyed by token name\n(e.g. \"Title\", \"Subtitle\", \"Custom.CompanySecretary\").\nCollected at workflow design time, applied at execution time.",
            "nullable": true
          },
          "portalFolderPath": {
            "maxLength": 500,
            "type": "string",
            "description": "Default portal folder path for the document.\nPre-fills the upload form for manual uploads; applied directly when generating\nfrom a template (where null means the practice's filing folder for generated documents).",
            "nullable": true
          },
          "storageFolderPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for the document, beside the portal folder.\nMay hold tokens. Null for the practice's filing folder for generated documents (a manual\nupload: the client's folder); \"/\" for the client's folder itself.",
            "nullable": true
          },
          "senderSource": {
            "$ref": "#/components/schemas/WorkflowEmailSenderSource"
          },
          "senderMailboxCode": {
            "maxLength": 50,
            "type": "string",
            "description": "The email connection to send from when SenderSource is SpecificMailbox. Ignored otherwise,\nand required when SenderSource is SpecificMailbox.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for DocumentApproval workflow steps.\nUsed for both workflow template definition and task workflow step instance customization."
      },
      "DocumentBulkActionResultDto": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentActionResultDto"
            },
            "description": "One entry per document code submitted, in the order they were sent.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of a bulk document action. Documents are handled independently, so a batch\ncan contain a mix of successes and failures."
      },
      "DocumentCategoryDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this document category",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the document category",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying document categories",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A tenant-defined grouping used to classify client documents"
      },
      "DocumentCategoryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentCategoryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "DocumentCategorySortField": {
        "enum": [
          "SortOrder",
          "Name"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "DocumentFilingDefaultDto": {
        "type": "object",
        "properties": {
          "storagePath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder; null for the client's folder itself",
            "nullable": true
          },
          "portalPath": {
            "type": "string",
            "description": "Folder in the client portal; null for the top of the portal",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Where a document of one kind is filed when nobody chooses: shown wherever staff can choose\ninstead. Either as the practice configured it (tokens included) or worked out for one client."
      },
      "DocumentFilingSettingsDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier for the settings",
            "nullable": true
          },
          "clientFolder_Name": {
            "type": "string",
            "description": "The name of the folder made for each client under the base folder, when Sodium creates client\nfolders. A \"/\" makes a folder inside a folder. Only folders made from now on use it.",
            "nullable": true
          },
          "documentRequests_StoragePath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for files uploaded to a document request. Empty for the client's folder itself.",
            "nullable": true
          },
          "documentRequests_PortalPath": {
            "type": "string",
            "description": "Client portal folder for files uploaded to a document request. Empty for the portal root. Used when the practice publishes a request's files without choosing a folder.",
            "nullable": true
          },
          "documentRequests_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether files uploaded to a document request appear in the portal in the same folder as in storage, instead of DocumentRequests_PortalPath"
          },
          "generatedDocuments_StoragePath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for documents created from a template, by staff or a workflow step. Empty for the client's folder itself.",
            "nullable": true
          },
          "generatedDocuments_PortalPath": {
            "type": "string",
            "description": "Client portal folder for documents created from a template, by staff or a workflow step. Empty for the portal root. Used unless a folder was chosen for the document.",
            "nullable": true
          },
          "generatedDocuments_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether documents created from a template, by staff or a workflow step appear in the portal in the same folder as in storage, instead of GeneratedDocuments_PortalPath"
          },
          "formExports_StoragePath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for form answers saved as a PDF. Empty for the client's folder itself.",
            "nullable": true
          },
          "formExports_PortalPath": {
            "type": "string",
            "description": "Client portal folder for form answers saved as a PDF. Empty for the portal root. Used unless a folder was chosen for the document.",
            "nullable": true
          },
          "formExports_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether form answers saved as a PDF appear in the portal in the same folder as in storage, instead of FormExports_PortalPath"
          },
          "formUploads_StoragePath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for files clients upload in a form. Empty for the client's folder itself.",
            "nullable": true
          },
          "formUploads_PortalPath": {
            "type": "string",
            "description": "Client portal folder for files clients upload in a form. Empty for the portal root.",
            "nullable": true
          },
          "formUploads_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether files clients upload in a form appear in the portal in the same folder as in storage, instead of FormUploads_PortalPath"
          },
          "proposals_StoragePath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for the signed proposal saved when an engagement is accepted. Empty for the client's folder itself.",
            "nullable": true
          },
          "proposals_PortalPath": {
            "type": "string",
            "description": "Client portal folder for the signed proposal saved when an engagement is accepted. Empty for the portal root.",
            "nullable": true
          },
          "proposals_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether the signed proposal saved when an engagement is accepted appear in the portal in the same folder as in storage, instead of Proposals_PortalPath"
          },
          "engagementLetters_StoragePath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for the signed letter of engagement. Empty for the client's folder itself.",
            "nullable": true
          },
          "engagementLetters_PortalPath": {
            "type": "string",
            "description": "Client portal folder for the signed letter of engagement. Empty for the portal root.",
            "nullable": true
          },
          "engagementLetters_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether the signed letter of engagement appear in the portal in the same folder as in storage, instead of EngagementLetters_PortalPath"
          },
          "portalUploads_StoragePath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for files clients upload on the portal's Documents page. Empty for the client's folder itself.",
            "nullable": true
          },
          "portalUploads_PortalPath": {
            "type": "string",
            "description": "Client portal folder for files clients upload on the portal's Documents page. Empty for the portal root.",
            "nullable": true
          },
          "portalUploads_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether files clients upload on the portal's Documents page appear in the portal in the same folder as in storage, instead of PortalUploads_PortalPath"
          },
          "savedAttachments_StoragePath": {
            "type": "string",
            "description": "Subfolder of the client's storage folder for email, WhatsApp and text attachments saved to the client. Empty for the client's folder itself.",
            "nullable": true
          },
          "savedAttachments_PortalPath": {
            "type": "string",
            "description": "Client portal folder for email, WhatsApp and text attachments saved to the client. Empty for the portal root. Used unless a folder was chosen when saving.",
            "nullable": true
          },
          "savedAttachments_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether email, WhatsApp and text attachments saved to the client appear in the portal in the same folder as in storage, instead of SavedAttachments_PortalPath"
          }
        },
        "additionalProperties": false,
        "description": "Where the practice's client documents are filed: each client's folder name in the connected\ndocument storage and, for each kind of document, its subfolder there and its folder in the client\nportal. Paths are \"/\"-separated and may hold Liquid tokens: client tokens, dates, and for document\nrequests Request.Code and Request.Title."
      },
      "DocumentFilingSource": {
        "enum": [
          "DocumentRequest",
          "GeneratedDocument",
          "FormExport",
          "FormUpload",
          "Proposal",
          "EngagementLetter",
          "PortalUpload",
          "SavedAttachment"
        ],
        "type": "string",
        "example": "DocumentRequest"
      },
      "DocumentMoveResultDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The document code, so the caller can match this result to the document it sent.",
            "nullable": true
          },
          "success": {
            "type": "boolean",
            "description": "Whether the document was moved."
          },
          "error": {
            "type": "string",
            "description": "A message explaining why the move failed. Null when it succeeded.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of moving a single document within a batch move."
      },
      "DocumentRequestDetailDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for this document request",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "title": {
            "type": "string",
            "description": "Title describing what documents are needed",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Detailed description of what is needed",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/DocumentRequestStatus"
          },
          "deadline": {
            "type": "string",
            "description": "Optional deadline for the client to respond by",
            "format": "date",
            "nullable": true
          },
          "documentCount": {
            "type": "integer",
            "description": "Number of documents attached to this request",
            "format": "int32"
          },
          "itemCount": {
            "type": "integer",
            "description": "Number of items on the request. Zero is a single ask, answered and reviewed as a whole; any\nitems are answered and reviewed one by one.",
            "format": "int32"
          },
          "withClientItemCount": {
            "type": "integer",
            "description": "Items with the client: outstanding or sent back",
            "format": "int32"
          },
          "toReviewItemCount": {
            "type": "integer",
            "description": "Items answered and waiting for the practice",
            "format": "int32"
          },
          "resolvedItemCount": {
            "type": "integer",
            "description": "Items resolved",
            "format": "int32"
          },
          "itemsChangedSinceNotified": {
            "type": "boolean",
            "description": "Items were added since the client was last emailed about the request"
          },
          "storageFolderPath": {
            "type": "string",
            "description": "Where the request's files are stored, under the client's storage folder, instead of the practice's filing\nfolder for request uploads. May hold tokens (client, dates, Request.Code). Set with the portal folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          },
          "portalFolderPath": {
            "type": "string",
            "description": "The client portal folder the request's files are filed in, instead of the practice's filing folder for request\nuploads. May hold tokens. Set with the storage folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          },
          "needsReview": {
            "type": "boolean",
            "description": "Whether the request has something for the practice to look at: a whole request submitted, or\nanswered items"
          },
          "notifyUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflowStepName": {
            "type": "string",
            "description": "Name of the workflow step that sent this request, which completes when the request is\naccepted. Null for document requests created manually.",
            "nullable": true
          },
          "taskCategory": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When the request was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the request was last updated",
            "format": "date-time",
            "nullable": true
          },
          "chase": {
            "$ref": "#/components/schemas/ChaseScheduleDto"
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientDocumentDto"
            },
            "description": "Documents attached to this request",
            "nullable": true
          },
          "responses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestResponseDto"
            },
            "description": "Submission responses for this request",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestItemDto"
            },
            "description": "The items, in number order. Empty for a request that is a single ask.",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientDocumentDto"
            },
            "description": "Files the practice attached to the request itself for the client to download and complete.\nFiles attached to one item are on that item.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Detailed response DTO for a document request, including documents and responses"
      },
      "DocumentRequestDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for this document request",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "title": {
            "type": "string",
            "description": "Title describing what documents are needed",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Detailed description of what is needed",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/DocumentRequestStatus"
          },
          "deadline": {
            "type": "string",
            "description": "Optional deadline for the client to respond by",
            "format": "date",
            "nullable": true
          },
          "documentCount": {
            "type": "integer",
            "description": "Number of documents attached to this request",
            "format": "int32"
          },
          "itemCount": {
            "type": "integer",
            "description": "Number of items on the request. Zero is a single ask, answered and reviewed as a whole; any\nitems are answered and reviewed one by one.",
            "format": "int32"
          },
          "withClientItemCount": {
            "type": "integer",
            "description": "Items with the client: outstanding or sent back",
            "format": "int32"
          },
          "toReviewItemCount": {
            "type": "integer",
            "description": "Items answered and waiting for the practice",
            "format": "int32"
          },
          "resolvedItemCount": {
            "type": "integer",
            "description": "Items resolved",
            "format": "int32"
          },
          "itemsChangedSinceNotified": {
            "type": "boolean",
            "description": "Items were added since the client was last emailed about the request"
          },
          "storageFolderPath": {
            "type": "string",
            "description": "Where the request's files are stored, under the client's storage folder, instead of the practice's filing\nfolder for request uploads. May hold tokens (client, dates, Request.Code). Set with the portal folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          },
          "portalFolderPath": {
            "type": "string",
            "description": "The client portal folder the request's files are filed in, instead of the practice's filing folder for request\nuploads. May hold tokens. Set with the storage folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          },
          "needsReview": {
            "type": "boolean",
            "description": "Whether the request has something for the practice to look at: a whole request submitted, or\nanswered items"
          },
          "notifyUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflowStepName": {
            "type": "string",
            "description": "Name of the workflow step that sent this request, which completes when the request is\naccepted. Null for document requests created manually.",
            "nullable": true
          },
          "taskCategory": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When the request was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the request was last updated",
            "format": "date-time",
            "nullable": true
          },
          "chase": {
            "$ref": "#/components/schemas/ChaseScheduleDto"
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a document request"
      },
      "DocumentRequestDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "DocumentRequestExecutionStateDto": {
        "type": "object",
        "properties": {
          "documentRequestCode": {
            "type": "string",
            "description": "The code of the created document request.",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The client code the document request was created for.",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "description": "UTC timestamp of when the document request was created and opened.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Execution state for a DocumentRequest workflow step.\nContains information about the created document request after execution.\nRead-only - written by the system during step execution, never edited by users."
      },
      "DocumentRequestItemDecision": {
        "type": "object",
        "properties": {
          "number": {
            "type": "integer",
            "description": "The item's number",
            "format": "int32"
          },
          "action": {
            "$ref": "#/components/schemas/DocumentRequestItemReviewAction"
          },
          "note": {
            "maxLength": 2000,
            "type": "string",
            "description": "What the client still needs to do (required to send back), or a note on a resolve",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The practice's decision on one item"
      },
      "DocumentRequestItemDto": {
        "type": "object",
        "properties": {
          "number": {
            "type": "integer",
            "description": "The item's number on the request, which addresses it in every item route. Fixed once the\nrequest is sent; renumbered 1 to n while it is a Draft.",
            "format": "int32"
          },
          "kind": {
            "$ref": "#/components/schemas/DocumentRequestItemKind"
          },
          "text": {
            "type": "string",
            "description": "The question, or what document is wanted",
            "nullable": true
          },
          "transactionDate": {
            "type": "string",
            "description": "Date of the transaction the item asks about, when it is one",
            "format": "date",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "description": "Amount of the transaction the item asks about; may be negative",
            "format": "double",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "description": "The ISO 4217 code of the amount's currency; null for the practice currency",
            "nullable": true
          },
          "reference": {
            "type": "string",
            "description": "The transaction's description or reference as it appears on the statement",
            "nullable": true
          },
          "answerType": {
            "$ref": "#/components/schemas/CustomFieldDataType"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A Select item's choices; empty for any other type",
            "nullable": true
          },
          "externalId": {
            "type": "string",
            "description": "The source's id for what the item asks about, when it came from one (a bank transaction's\nexternalId). Compare it with a bank transaction list to mark lines already on the request.",
            "nullable": true
          },
          "section": {
            "type": "string",
            "description": "The heading the item sits under; null for none. Groups follow the order of each section's first\nitem, and items with no section come first.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/DocumentRequestItemStatus"
          },
          "answerText": {
            "type": "string",
            "description": "The answer as last sent",
            "nullable": true
          },
          "cannotProvide": {
            "type": "boolean",
            "description": "The client said they cannot provide this"
          },
          "answeredDate": {
            "type": "string",
            "description": "When the answer was last sent",
            "format": "date-time",
            "nullable": true
          },
          "answeredBy": {
            "type": "string",
            "description": "Who sent the answer: the portal contact's name, the magic link recipient's email, or the\nmember of staff who answered for the client",
            "nullable": true
          },
          "answeredByStaff": {
            "type": "boolean",
            "description": "Whether the answer was given by a member of staff on the client's behalf"
          },
          "hasUnsentDraft": {
            "type": "boolean",
            "description": "The client has something saved on this item that they have not sent. Its content stays with\nthe client until they send it."
          },
          "reviewNote": {
            "type": "string",
            "description": "The note with the last send back, or with a resolve",
            "nullable": true
          },
          "reviewedBy": {
            "type": "string",
            "description": "Name of the member of staff who last resolved it or sent it back",
            "nullable": true
          },
          "reviewedDate": {
            "type": "string",
            "description": "When it was last resolved or sent back",
            "format": "date-time",
            "nullable": true
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientDocumentDto"
            },
            "description": "Files the client sent for this item",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientDocumentDto"
            },
            "description": "Files the practice attached to this item for the client to download and complete",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One item on a document request, as the practice sees it"
      },
      "DocumentRequestItemHistoryEntryDto": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/DocumentRequestItemHistoryEntryType"
          },
          "date": {
            "type": "string",
            "description": "When it happened",
            "format": "date-time"
          },
          "byName": {
            "type": "string",
            "description": "Who did it: a member of staff, or for an answer from the client the contact's name or the\naddress it came from. Null when not known (the system, or the client before names were kept).",
            "nullable": true
          },
          "isAnsweredForClient": {
            "type": "boolean",
            "description": "An answer a member of staff gave on the client's behalf"
          },
          "text": {
            "type": "string",
            "description": "The answer sent (Answered), the note (SentBack, Resolved), or the new question (Added, Edited)",
            "nullable": true
          },
          "cannotProvide": {
            "type": "boolean",
            "description": "The answer was \"I don't have this\""
          }
        },
        "additionalProperties": false,
        "description": "One thing that happened to a document request item: added, edited, answered, sent back or resolved"
      },
      "DocumentRequestItemHistoryEntryType": {
        "enum": [
          "Added",
          "Edited",
          "Answered",
          "SentBack",
          "Resolved"
        ],
        "type": "string",
        "example": "Added"
      },
      "DocumentRequestItemInput": {
        "type": "object",
        "properties": {
          "number": {
            "type": "integer",
            "description": "When saving a Draft's whole list, the number of an existing item this entry keeps (with its\nfiles). Leave empty for a new item. Ignored when adding items.",
            "format": "int32",
            "nullable": true
          },
          "kind": {
            "$ref": "#/components/schemas/DocumentRequestItemKind"
          },
          "text": {
            "type": "string",
            "description": "The question, or what document is wanted (required, at most 1,000 characters)",
            "nullable": true
          },
          "transactionDate": {
            "type": "string",
            "description": "Date of the transaction the item asks about, when it is one",
            "format": "date",
            "nullable": true
          },
          "amount": {
            "maximum": 9999999999.99,
            "minimum": -9999999999.99,
            "type": "number",
            "description": "Amount of the transaction the item asks about; may be negative",
            "format": "double",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "description": "The ISO 4217 code of the amount's currency (USD). Leave empty for the practice currency.",
            "nullable": true
          },
          "reference": {
            "type": "string",
            "description": "The transaction's description or reference as it appears on the statement (at most 200 characters)",
            "nullable": true
          },
          "answerType": {
            "$ref": "#/components/schemas/CustomFieldDataType"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A Select item's choices; empty for any other type",
            "nullable": true
          },
          "externalId": {
            "maxLength": 200,
            "type": "string",
            "description": "The source's id for what a new item asks about: a bank transaction's externalId from the\nclient's books (at most 200 characters). Ignored for an existing item, which keeps the id it was\ncreated with.",
            "nullable": true
          },
          "section": {
            "maxLength": 200,
            "type": "string",
            "description": "The heading the item sits under (at most 200 characters). Blank or null for none; items with no\nsection come before every section.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An item to put on a document request"
      },
      "DocumentRequestItemKind": {
        "enum": [
          "Query",
          "Document"
        ],
        "type": "string",
        "example": "Query"
      },
      "DocumentRequestItemListDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The list's code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "What staff pick it by",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "What the list is for",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestStepItemDto"
            },
            "description": "The items, in order: kind and text (text may hold Liquid tokens, rendered when a request is made from it)",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether \"Use a saved list\" offers it"
          }
        },
        "additionalProperties": false,
        "description": "A practice's saved list of document request items, e.g. a year-end checklist. \"Use a saved list\" copies its\nitems into a request or a workflow step; nothing links back to the list."
      },
      "DocumentRequestItemListDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestItemListDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "DocumentRequestItemListSortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "DocumentRequestItemReviewAction": {
        "enum": [
          "Resolve",
          "SendBack"
        ],
        "type": "string",
        "example": "Resolve"
      },
      "DocumentRequestItemStatus": {
        "enum": [
          "Outstanding",
          "Answered",
          "SentBack",
          "Resolved"
        ],
        "type": "string",
        "example": "Outstanding"
      },
      "DocumentRequestItemsRequest": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestItemInput"
            },
            "description": "The items, in order. At most 250 on a request.",
            "nullable": true
          },
          "originalAsk": {
            "maxLength": 1000,
            "type": "string",
            "description": "Adding to a request that was sent as a single ask: what was asked, which becomes item 1, a\ndocument. It takes the client's files, and their submitted response as its answer. Required\nthere, refused elsewhere.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A list of items: a Draft's whole list when saving it, or the items to add"
      },
      "DocumentRequestRejectAction": {
        "enum": [
          "Reopen",
          "ReopenClearDocs"
        ],
        "type": "string",
        "example": "Reopen"
      },
      "DocumentRequestResponseDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for this response",
            "nullable": true
          },
          "comments": {
            "type": "string",
            "description": "Comments provided with the submission",
            "nullable": true
          },
          "submittedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "submittedByContact": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "submittedByEmail": {
            "type": "string",
            "description": "Email address of the recipient who submitted (from magic link token).",
            "nullable": true
          },
          "submittedDate": {
            "type": "string",
            "description": "When this response was submitted",
            "format": "date-time"
          },
          "reviewedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "reviewedDate": {
            "type": "string",
            "description": "When this response was reviewed",
            "format": "date-time",
            "nullable": true
          },
          "reviewStatus": {
            "$ref": "#/components/schemas/DocumentRequestResponseStatus"
          },
          "reviewNote": {
            "type": "string",
            "description": "Note provided by the reviewer",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When this response was created",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a document request submission/response"
      },
      "DocumentRequestResponseStatus": {
        "enum": [
          "Pending",
          "Accepted",
          "Rejected"
        ],
        "type": "string",
        "example": "Pending"
      },
      "DocumentRequestSortField": {
        "enum": [
          "Title",
          "Status",
          "CreatedDate",
          "Deadline",
          "DocumentCount",
          "ToReviewItemCount",
          "Progress"
        ],
        "type": "string",
        "example": "Title"
      },
      "DocumentRequestStatus": {
        "enum": [
          "Draft",
          "Open",
          "Submitted",
          "Accepted",
          "Rejected",
          "Cancelled"
        ],
        "type": "string",
        "example": "Draft"
      },
      "DocumentRequestStepConfigDto": {
        "required": [
          "title"
        ],
        "type": "object",
        "properties": {
          "title": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "The title for the document request to create.\nDescribes what documents are being requested from the client."
          },
          "description": {
            "type": "string",
            "description": "Optional description providing details about what documents are needed.",
            "nullable": true
          },
          "deadlineDaysFromExecution": {
            "maximum": 365,
            "minimum": 1,
            "type": "integer",
            "description": "Number of days from step execution to set as the client-facing deadline.\nFor example, 14 means the client has 14 days from when the step runs.\nNull means no deadline is set on the document request.",
            "format": "int32",
            "nullable": true
          },
          "notifyUserCode": {
            "maxLength": 50,
            "type": "string",
            "description": "Code of the user to notify when the client submits a response.\nDefaults to the step's assigned user at execution time. Only set this\nto override the default — most workflows should leave it null.",
            "nullable": true
          },
          "storageFolderPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Where the files returned to the request this step sends are stored, under the client's storage folder, instead of the practice's filing\nfolder for request uploads. May hold tokens (client, dates, Request.Code). Set with the portal folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          },
          "portalFolderPath": {
            "maxLength": 400,
            "type": "string",
            "description": "The client portal folder the files returned to the request this step sends are filed in, instead of the practice's filing folder for request\nuploads. May hold tokens. Set with the storage folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          },
          "items": {
            "maxItems": 250,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestStepItemDto"
            },
            "description": "Items to put on the request, in order (at most 250). Empty or absent means a request without\nitems. A step whose items differ every time leaves this empty and adds them on the draft request.",
            "nullable": true
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to send the document request email to the client's business email\n(the email address on the client record)."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types to send the document request email to.\nResolved at execution time from the task's associated client contacts.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to send the document request email to.",
            "nullable": true
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for how often (in days) to chase this document request.\nWhen null, the tenant-level default is used.",
            "format": "int32",
            "nullable": true
          },
          "alsoSendText": {
            "type": "boolean",
            "description": "Also text each email recipient who is one of the client's contacts with a mobile, by SMS, with the same link as\ntheir email, worded by the practice's text wording for this kind of request. Ignored while the practice's\nmessaging is not Active."
          },
          "senderSource": {
            "$ref": "#/components/schemas/WorkflowEmailSenderSource"
          },
          "senderMailboxCode": {
            "maxLength": 50,
            "type": "string",
            "description": "The email connection to send from when SenderSource is SpecificMailbox. Ignored otherwise,\nand required when SenderSource is SpecificMailbox.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for DocumentRequest workflow steps.\nUsed for both workflow template definition and task workflow step instance customization."
      },
      "DocumentRequestStepItemDto": {
        "required": [
          "text"
        ],
        "type": "object",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/DocumentRequestItemKind"
          },
          "text": {
            "maxLength": 1000,
            "minLength": 1,
            "type": "string",
            "description": "The question, or what document is wanted (required, at most 1,000 characters). Supports Liquid\ntemplate syntax (e.g. {{ Client.Name }}), rendered when the step creates its request."
          },
          "answerType": {
            "$ref": "#/components/schemas/CustomFieldDataType"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A Select item's choices; empty for any other type",
            "nullable": true
          },
          "section": {
            "maxLength": 200,
            "type": "string",
            "description": "The heading the item sits under on the request (at most 200 characters); blank or null for none. Supports\nLiquid template syntax like SodiumHQ.DTOs.WorkflowSteps.DocumentRequestStepItemDto.Text, rendered with the item's own tokens, so a repeated item can\nuse {{ Line }} here too.",
            "nullable": true
          },
          "repeatOverCustomFieldCode": {
            "maxLength": 50,
            "type": "string",
            "description": "Code of a client custom field (Long Text or Multi-select) this item repeats over. When the step creates its\nrequest, it adds one item for each line of the client's value (each choice of a multi-select), with that line\nas {{ Line }} in the text, e.g. \"{{ Line }} statement for {{ Month.Name }}\". A client with no value gets none of\nthem. Null for an ordinary item. Ignored when a saved list is used on a request outside a workflow.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An item a Document Request step puts on the request it creates"
      },
      "DocumentRequestTokens": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The request's code",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "What the request asks for",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The document request a file was uploaded to, for the folder it is filed in.\nUsage in a filing path: Document Requests/{{ Request.Code }}"
      },
      "DocumentTemplateDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "type": {
            "$ref": "#/components/schemas/TemplateType"
          },
          "bodyHtml": {
            "type": "string",
            "description": "The template content using Liquid/Fluid syntax with variables ({{ client.Name }}),\nloops ({% for %}), conditionals ({% if %}), and content block references",
            "nullable": true
          },
          "outputNameTemplate": {
            "type": "string",
            "description": "Optional template for naming rendered documents using {{ token }} placeholders.\nWhen null, documents use the template's Name.",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether this template is available for use (inactive templates are hidden but preserved)"
          },
          "defaultDesignTheme": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "dataForm": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When this template was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When this template was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Reusable document template for generating HTML documents such as proposals, engagement letters, reports, and invoices.\nTemplates use Liquid/Fluid syntax for dynamic content, variables, loops, and conditionals.\nCan reference content blocks and be styled with design themes for consistent branding."
      },
      "DocumentTemplateDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentTemplateDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "DocumentTemplateSortField": {
        "enum": [
          "Name",
          "UpdatedDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "DocumentTemplateTokenInfo": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The token key used for form values (e.g. \"Title\", \"Custom.InvoiceRef\")",
            "nullable": true
          },
          "label": {
            "type": "string",
            "description": "Human-readable display label for the token (e.g. \"Invoice Ref\").\nFalls back to Name if not set.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional description/prompt text for the token (from custom token definition)",
            "nullable": true
          },
          "defaultValue": {
            "type": "string",
            "description": "Optional default value for the token (from custom token definition)",
            "nullable": true
          },
          "isCustomToken": {
            "type": "boolean",
            "description": "Whether this token is a user-defined custom token (Custom.* prefix)"
          },
          "displayWidth": {
            "type": "string",
            "description": "Preset display width for the input (from custom token definition). Null defaults to Full.",
            "nullable": true
          },
          "lines": {
            "type": "integer",
            "description": "Number of visible text lines (from custom token definition). Null renders a single-line input.",
            "format": "int32",
            "nullable": true
          },
          "isRichText": {
            "type": "boolean",
            "description": "When true, the input renders as a rich text editor. The value will contain HTML."
          },
          "isNumber": {
            "type": "boolean",
            "description": "When true, the input takes a number (from custom token definition)."
          }
        },
        "additionalProperties": false,
        "description": "Information about a token found in a document template,\nincluding metadata from custom token definitions when available."
      },
      "DocumentUploadBatchResultDto": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentUploadResultDto"
            },
            "description": "One entry per file uploaded, in the order they were submitted.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of a batch document upload. Files are uploaded independently, so a batch\ncan contain a mix of successes and failures."
      },
      "DocumentUploadExecutionStateDto": {
        "type": "object",
        "properties": {
          "documentCode": {
            "type": "string",
            "description": "The code of the uploaded document.",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The client code the document belongs to.",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "description": "UTC timestamp of when the document was linked to this step.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Execution state for a DocumentUpload workflow step.\nContains information about the uploaded document.\nRead-only - written by the system during step execution, never edited by users."
      },
      "DocumentUploadResultDto": {
        "type": "object",
        "properties": {
          "fileName": {
            "type": "string",
            "description": "The original file name, so the caller can match this result to the file it sent.",
            "nullable": true
          },
          "success": {
            "type": "boolean",
            "description": "Whether the file was stored successfully."
          },
          "document": {
            "$ref": "#/components/schemas/ClientDocumentDto"
          },
          "error": {
            "type": "string",
            "description": "A message explaining why the upload failed. Null when it succeeded.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of uploading a single file within a batch upload."
      },
      "DocumentUploadStepConfigDto": {
        "type": "object",
        "properties": {
          "title": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional default title for the document.\nPre-fills the upload form so the user only needs to select the file.",
            "nullable": true
          },
          "summary": {
            "maxLength": 2000,
            "type": "string",
            "description": "Optional default summary for the document.\nPre-fills the upload form so the user only needs to select the file.",
            "nullable": true
          },
          "categoryCode": {
            "maxLength": 50,
            "type": "string",
            "description": "Optional default document category code.\nPre-fills the category dropdown on the upload form.",
            "nullable": true
          },
          "sendNotification": {
            "type": "boolean",
            "description": "Whether to send the client a notification email with a link to view the document.\nWhen false, the step completes as soon as the document is uploaded."
          },
          "message": {
            "type": "string",
            "description": "Optional personal message included in the notification email via the\n{{ Message }} template token. May contain HTML and template tokens.\nOnly used when SendNotification is true.",
            "nullable": true
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to send the notification email to the client's business email\n(the email address on the client record). Only used when SendNotification is true."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types to send the notification email to.\nResolved at execution time from the task's associated client contacts.\nOnly used when SendNotification is true.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to send the notification email to.\nOnly used when SendNotification is true.",
            "nullable": true
          },
          "includeAttachment": {
            "type": "boolean",
            "description": "Whether to attach the document file to the notification email\nin addition to the view link. Only used when SendNotification is true."
          },
          "documentTemplate": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "designThemeCode": {
            "maxLength": 50,
            "type": "string",
            "description": "Optional design theme override for PDF generation.\nWhen null, uses the template's default theme.",
            "nullable": true
          },
          "templateTokenValues": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Token values for template rendering, keyed by token name\n(e.g. \"Title\", \"Subtitle\", \"Custom.CompanySecretary\").\nCollected at workflow design time, applied at execution time.",
            "nullable": true
          },
          "portalFolderPath": {
            "maxLength": 500,
            "type": "string",
            "description": "Default portal folder path for the document.\nPre-fills the upload form for manual uploads; applied directly when generating\nfrom a template (where null means the practice's filing folder for generated documents).",
            "nullable": true
          },
          "storageFolderPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for the document, beside the portal folder.\nMay hold tokens. Null for the practice's filing folder for generated documents (a manual\nupload: the client's folder); \"/\" for the client's folder itself.",
            "nullable": true
          },
          "visibleInClientPortal": {
            "type": "boolean",
            "description": "Default for whether the document is visible to the client in the portal.\nIgnored (treated as true) when SendNotification is true — notifying the client\nrequires the document to be visible in the portal."
          },
          "senderSource": {
            "$ref": "#/components/schemas/WorkflowEmailSenderSource"
          },
          "senderMailboxCode": {
            "maxLength": 50,
            "type": "string",
            "description": "The email connection to send from when SenderSource is SpecificMailbox. Ignored otherwise,\nand required when SenderSource is SpecificMailbox.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for DocumentUpload (Upload a Document) workflow steps.\nUsed for both workflow template definition and task workflow step instance customization."
      },
      "DraftOperationResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the operation succeeded"
          },
          "errorMessage": {
            "type": "string",
            "description": "Error message if the operation failed",
            "nullable": true
          },
          "reconnectRequired": {
            "type": "boolean",
            "description": "Whether the user needs to reconnect their mailbox"
          }
        },
        "additionalProperties": false,
        "description": "Response shared by the update/send/delete draft endpoints — all three are a single provider\ncall with the same success/failure shape as Sodium.EmailService.Contracts.Responses.ReplyEmailResponse."
      },
      "DueDateConfigDto": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/DueDateType"
          },
          "interval": {
            "$ref": "#/components/schemas/RelativeIntervalDto"
          },
          "date": {
            "type": "string",
            "description": "The first Due date of the cycle, year included. Required when Type is SpecificDate and the Due\ndate drives the schedule (Schedule.Basis is DueDate): the cycle starts here and nothing is\ncreated before it, and FixedMonth/FixedDay are taken from it. Omitted when the Due date is\nderived from the Start, which uses FixedMonth/FixedDay (DD/MM annual) instead.",
            "format": "date-time",
            "nullable": true
          },
          "fixedMonth": {
            "type": "integer",
            "description": "Month (1-12). Required when Type is SpecificDate and Due does not drive the schedule; otherwise taken from Date.",
            "format": "int32",
            "nullable": true
          },
          "fixedDay": {
            "type": "integer",
            "description": "Day of month (1-31). Required when Type is SpecificDate and Due does not drive the schedule; otherwise taken from Date. Clamped to last day of month at projection time.",
            "format": "int32",
            "nullable": true
          },
          "clientDateSourceType": {
            "$ref": "#/components/schemas/ClientDateSourceType"
          },
          "clientDateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "customFieldDefinitionCode": {
            "type": "string",
            "description": "Custom field code. Required when Type is ClientKeyDate and ClientDateSourceType is CustomField.",
            "nullable": true
          },
          "customFieldDefinitionLabel": {
            "type": "string",
            "description": "Custom field label. Populated in responses only.",
            "nullable": true
          },
          "timing": {
            "$ref": "#/components/schemas/DaysBeforeOrAfter"
          },
          "offsetDays": {
            "type": "integer",
            "description": "Number of days before or after the client date. Required when Type is ClientKeyDate.\nPaired with OffsetMonths for composite offsets like \"9 months + 1 day\" (CT payment).",
            "format": "int32",
            "nullable": true
          },
          "offsetMonths": {
            "type": "integer",
            "description": "Number of months before or after the client date. Paired with OffsetDays. NULL when no months\nportion is needed. Used when Type is ClientKeyDate.",
            "format": "int32",
            "nullable": true
          },
          "dayOfMonth": {
            "type": "integer",
            "description": "Day of month (1-31). Required when Type is DayOfMonth. Clamped to end-of-month for shorter\nmonths (e.g. 31 -> 28 in non-leap February). Requires monthly cadence.",
            "format": "int32",
            "nullable": true
          },
          "monthDayPatterns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WeekDayPatternDto"
            },
            "description": "Positional weekday patterns within each occurrence's month. Required when Type is MonthDay.\nExample: [{ Position: \"First\", Day: \"Monday\" }, { Position: \"Last\", Day: \"Friday\" }].\nRequires monthly or yearly cadence.",
            "nullable": true
          },
          "sequenceSeedDate": {
            "type": "string",
            "description": "The first Due date of the repeating cycle (the sequence seed). Required when Type is\nSequence; the Due advances from here through Recurrence.Sequence, wrapping indefinitely.",
            "format": "date-time",
            "nullable": true
          },
          "holidayAdjustment": {
            "$ref": "#/components/schemas/HolidayAdjustment"
          },
          "time": {
            "type": "string",
            "description": "Time of day stamped onto every projected Due date. Omit for 09:00; always populated in\nresponses.",
            "format": "time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for the projected DueDate on tasks created from a recurring task.\nDifferent properties are required based on the Type value:\n- RelativeToStart: Interval (e.g., 2 weeks after StartDate)\n- SpecificDate: Date (a full date) when Due drives the schedule, otherwise FixedMonth + FixedDay\n  (DD/MM annual; invalid days clamped to end-of-month)\n- ClientKeyDate: ClientDateSourceType + Timing + OffsetDays + OffsetMonths, plus ClientDateType (KeyDate) or CustomFieldDefinitionCode (CustomField)\n- DayOfMonth: DayOfMonth (1-31, clamped to end-of-month for shorter months) - requires monthly cadence\n- MonthDay: MonthDayPatterns (positional weekday list, e.g. First Monday) - requires monthly/yearly cadence\n- RelativeToStatutory: Interval (Due = Statutory - interval) - requires TaskDateBasis=StatutoryDate\n- Sequence: SequenceSeedDate + Recurrence.Sequence (Due advances through the repeating periods\n  from the seed) - requires TaskDateBasis=DueDate"
      },
      "DueDateType": {
        "enum": [
          "RelativeToStart",
          "SpecificDate",
          "ClientKeyDate",
          "DayOfMonth",
          "MonthDay",
          "RelativeToStatutory",
          "Sequence"
        ],
        "type": "string",
        "example": "RelativeToStart"
      },
      "EmailAddressClassificationDto": {
        "type": "object",
        "properties": {
          "address": {
            "type": "string",
            "description": "The address, lower-cased",
            "nullable": true
          },
          "kind": {
            "$ref": "#/components/schemas/EmailAddressKind"
          },
          "clientCode": {
            "type": "string",
            "description": "The matched client, when exactly one client matches and the caller may see it",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The matched client's name, alongside ClientCode",
            "nullable": true
          },
          "clientCount": {
            "type": "integer",
            "description": "How many clients the address matches (Client only)",
            "format": "int32"
          },
          "matchedBy": {
            "$ref": "#/components/schemas/EmailAddressMatch"
          }
        },
        "additionalProperties": false,
        "description": "What one email address is to the practice. The practice's own addresses come first, then a client\nmatch (address before domain), then a not-client marker (address before domain)."
      },
      "EmailAddressClientMatchDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name",
            "nullable": true
          },
          "matchedVia": {
            "type": "string",
            "description": "\"Client\" when it is the client's own email, else the name of the contact who has it",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client an email address is also on"
      },
      "EmailAddressKind": {
        "enum": [
          "Unknown",
          "Client",
          "NotClient",
          "Internal"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "EmailAddressMatch": {
        "enum": [
          "Address",
          "Domain"
        ],
        "type": "string",
        "example": "Address"
      },
      "EmailAttachmentDto": {
        "required": [
          "contentType",
          "fileName"
        ],
        "type": "object",
        "properties": {
          "fileName": {
            "minLength": 1,
            "type": "string",
            "description": "File name"
          },
          "contentType": {
            "minLength": 1,
            "type": "string",
            "description": "MIME content type"
          },
          "contentBase64": {
            "type": "string",
            "description": "Base64 encoded file content (Option 1)",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "URL to download attachment from (Option 2)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Email attachment DTO"
      },
      "EmailAttachmentInfoDto": {
        "type": "object",
        "properties": {
          "uniqueId": {
            "type": "string",
            "description": "Unique attachment identifier",
            "format": "uuid"
          },
          "fileName": {
            "type": "string",
            "description": "File name",
            "nullable": true
          },
          "contentType": {
            "type": "string",
            "description": "MIME content type",
            "nullable": true
          },
          "size": {
            "type": "integer",
            "description": "File size in bytes",
            "format": "int64",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Email attachment information DTO (for responses)"
      },
      "EmailBroadcastAudienceRequest": {
        "type": "object",
        "properties": {
          "savedViewCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The code of a saved client view whose filter selects which clients to include.\nMutually exclusive with Filter.",
            "nullable": true,
            "example": "active-limited-companies"
          },
          "filter": {
            "$ref": "#/components/schemas/EmailBroadcastFilterDto"
          },
          "excludedClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Client codes to exclude from the filter results.",
            "nullable": true
          },
          "additionalClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hand-picked client codes to add on top of the filter results.",
            "nullable": true
          },
          "allContacts": {
            "type": "boolean",
            "description": "When true, every contact of each client with an email address is a To recipient.\nPart of the optional To-recipient configuration used to count clients with no\nresolvable email address (NoEmailCount).",
            "example": false
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether each client's business email (the email address on the client record) is a\nTo recipient. Part of the optional To-recipient configuration."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for To recipients. Part of the optional To-recipient configuration.",
            "nullable": true
          },
          "recipientUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for To recipients. Part of the optional To-recipient configuration.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses included as To recipients on every email.\nPart of the optional To-recipient configuration.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The client-selection part of an email broadcast, used to summarise the audience\nbefore a draft exists. Same selection semantics as create: a saved view or an\ninline filter (mutually exclusive), plus hand-picked additions and exclusions.\nOptionally include the To-recipient configuration to also count clients with\nno resolvable email address."
      },
      "EmailBroadcastAudienceSummaryDto": {
        "type": "object",
        "properties": {
          "clientCount": {
            "type": "integer",
            "description": "Total number of clients the selection resolves to (filter matches plus\nhand-picked additions, minus exclusions).",
            "format": "int32",
            "example": 142
          },
          "notEmailableCount": {
            "type": "integer",
            "description": "How many of those clients have an email contact preference that is not set —\nthey are skipped at send time unless the broadcast opts to include them.",
            "format": "int32",
            "example": 7
          },
          "noEmailCount": {
            "type": "integer",
            "description": "How many of the clients have no resolvable email address for the requested\nTo-recipient configuration — they are always skipped at send time.\nNull when the request did not include a To-recipient configuration.",
            "format": "int32",
            "nullable": true,
            "example": 3
          }
        },
        "additionalProperties": false,
        "description": "Summary counts for an email broadcast audience: how many clients the selection\nresolves to, and how many of those have not opted in to email contact."
      },
      "EmailBroadcastDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying this broadcast",
            "nullable": true,
            "example": "a1b2c3d4e5f64a7b8c9d0e1f2a3b4c5d"
          },
          "status": {
            "$ref": "#/components/schemas/EmailBroadcastStatus"
          },
          "contentBlockCode": {
            "type": "string",
            "description": "Content block code (category: Email) used as the email template.\nMutually exclusive with SubjectLine/BodyHtml.",
            "nullable": true,
            "example": "client-newsletter"
          },
          "subjectLine": {
            "type": "string",
            "description": "Inline email subject line with Liquid template syntax.\nMutually exclusive with ContentBlockCode.",
            "nullable": true,
            "example": "An update for {{ Client.Name }}"
          },
          "bodyHtml": {
            "type": "string",
            "description": "Inline email body HTML with Liquid template syntax.\nMutually exclusive with ContentBlockCode.",
            "nullable": true
          },
          "allContacts": {
            "type": "boolean",
            "description": "When true, every contact of each client with an email address receives the email\nas a To recipient, regardless of contact type. RecipientContactTypes is ignored.",
            "example": false
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether each client's business email (the email address on the client record)\nis included as a To recipient. Applies whether or not AllContacts is set."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for To recipients, resolved per client at send time.\nIgnored when AllContacts is true.",
            "nullable": true
          },
          "recipientUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for To recipients (ClientManager, ClientPartner, ClientAssociate, ClientServiceManager),\nresolved per client at send time.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses included as To recipients on every email.",
            "nullable": true
          },
          "ccIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether each client's business email is included as a CC recipient."
          },
          "ccContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for CC recipients.",
            "nullable": true
          },
          "ccUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for CC recipients.",
            "nullable": true
          },
          "ccEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses included as CC recipients on every email.",
            "nullable": true
          },
          "bccIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether each client's business email is included as a BCC recipient."
          },
          "bccContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for BCC recipients.",
            "nullable": true
          },
          "bccUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for BCC recipients.",
            "nullable": true
          },
          "bccEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses included as BCC recipients on every email.",
            "nullable": true
          },
          "savedView": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "filter": {
            "$ref": "#/components/schemas/EmailBroadcastFilterDto"
          },
          "excludedClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Client codes excluded from the filter results.",
            "nullable": true
          },
          "additionalClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hand-picked client codes added on top of the filter results.",
            "nullable": true
          },
          "onlyEmailableClients": {
            "type": "boolean",
            "description": "When true, clients whose email contact preference is not set are skipped.",
            "example": true
          },
          "sendOncePerAddress": {
            "type": "boolean",
            "description": "When true, a contact address on several selected clients gets one copy (the first client's).",
            "example": false
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepEmailPreviewAttachmentDto"
            },
            "description": "Practice document attachments (metadata only) attached to every email in the broadcast.\nPopulated on the single-broadcast endpoints (get, create, update); empty in list responses.\nDocuments that no longer exist are omitted; send-time validation surfaces the breakage.",
            "nullable": true
          },
          "addHeaderFooter": {
            "type": "boolean",
            "description": "When true, the tenant's email header and footer content blocks are wrapped\naround the body when the email is rendered.",
            "example": true
          },
          "configCode": {
            "type": "string",
            "description": "The email configuration (mailbox) code to send from.\nNull uses the tenant's default mailbox resolution.",
            "nullable": true,
            "example": "billing-mailbox"
          },
          "totalClients": {
            "type": "integer",
            "description": "Total number of sendable recipients, set when the broadcast is sent.",
            "format": "int32",
            "example": 142
          },
          "processedClients": {
            "type": "integer",
            "description": "Number of recipients processed so far (sent + failed).\nCompare with TotalClients to calculate progress.",
            "format": "int32",
            "example": 75
          },
          "failedClients": {
            "type": "integer",
            "description": "Number of recipients that failed so far.",
            "format": "int32",
            "example": 2
          },
          "scheduledAt": {
            "type": "string",
            "description": "When a Scheduled broadcast will be dispatched (UTC). Populated on the single-broadcast\nGET only while the broadcast is Scheduled; null otherwise and in list responses.",
            "format": "date-time",
            "nullable": true
          },
          "startedDate": {
            "type": "string",
            "description": "When the broadcast started sending (UTC). Null until processing starts.",
            "format": "date-time",
            "nullable": true
          },
          "completedDate": {
            "type": "string",
            "description": "When the broadcast finished processing (UTC). Set for completion, failure and cancellation.",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the broadcast was created (UTC).",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "An email broadcast: an ad-hoc mass email to a filtered set of clients with per-client\nLiquid token rendering. Returned by the email broadcast endpoints."
      },
      "EmailBroadcastDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailBroadcastDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "EmailBroadcastFilterDto": {
        "type": "object",
        "properties": {
          "managerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by their assigned manager's code(s).",
            "nullable": true,
            "example": [
              "MGR001"
            ]
          },
          "partnerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by their assigned partner's code(s).",
            "nullable": true,
            "example": [
              "PTR001"
            ]
          },
          "associateCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by their assigned associate's code(s).",
            "nullable": true,
            "example": [
              "ASC001"
            ]
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientStatus"
            },
            "description": "Filter clients by status(es).\nValues: Active, Inactive, Prospect, LostProspect",
            "nullable": true,
            "example": [
              "Active"
            ]
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "Filter clients by their organization type(s).",
            "nullable": true,
            "example": [
              "PrivateLimitedCompany"
            ]
          },
          "serviceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by billable service code(s) they have assigned.",
            "nullable": true,
            "example": [
              "SVC001"
            ]
          },
          "packageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by service package code(s) they have assigned.",
            "nullable": true,
            "example": [
              "PKG001"
            ]
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by their assigned team's code(s).",
            "nullable": true,
            "example": [
              "TEAM001"
            ]
          },
          "serviceStageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter clients by service stage composite codes (format: \"serviceCode:stageCode\").",
            "nullable": true,
            "example": [
              "SVC001:in-progress"
            ]
          },
          "serviceStatuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceStatus"
            },
            "description": "Service statuses a client's service must have: the chosen service's, or any service's when no service or stage is filtered. Null means any status.",
            "nullable": true,
            "example": [
              "Active"
            ]
          },
          "search": {
            "type": "string",
            "description": "Search across client code, name and internal reference.\nMinimum 3 characters.",
            "nullable": true,
            "example": "acme"
          }
        },
        "additionalProperties": false,
        "description": "Filter criteria for selecting which clients receive an email broadcast.\nSame wire shape as the CSV export filter — matches the filters on the client list endpoint.\nIf the filter is omitted entirely, only AdditionalClientCodes are included (pure hand-picked list).\nAn empty filter object selects all clients."
      },
      "EmailBroadcastPreviewDto": {
        "type": "object",
        "properties": {
          "subject": {
            "type": "string",
            "description": "Rendered subject line with Liquid tokens resolved for the sample client.",
            "nullable": true
          },
          "bodyHtml": {
            "type": "string",
            "description": "Rendered body HTML with header/footer/theme applied and Liquid tokens resolved for the sample client.",
            "nullable": true
          },
          "toRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailPreviewRecipientDto"
            },
            "description": "Resolved To recipients for the sample client.",
            "nullable": true
          },
          "ccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailPreviewRecipientDto"
            },
            "description": "Resolved CC recipients for the sample client.",
            "nullable": true
          },
          "bccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailPreviewRecipientDto"
            },
            "description": "Resolved BCC recipients for the sample client.",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepEmailPreviewAttachmentDto"
            },
            "description": "Practice document attachments (metadata only) that will be attached to every email.\nDocuments that no longer exist are omitted; send-time validation surfaces the breakage.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Preview of a broadcast email rendered for a specific sample client, with resolved recipients.\nReturned before sending so the user can review what will be sent."
      },
      "EmailBroadcastRecipientDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code",
            "nullable": true,
            "example": "acme-ltd"
          },
          "clientName": {
            "type": "string",
            "description": "The client's name",
            "nullable": true,
            "example": "ACME Ltd"
          },
          "toRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailPreviewRecipientDto"
            },
            "description": "Resolved To recipients for this client's email.",
            "nullable": true
          },
          "ccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailPreviewRecipientDto"
            },
            "description": "Resolved CC recipients for this client's email.",
            "nullable": true
          },
          "bccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailPreviewRecipientDto"
            },
            "description": "Resolved BCC recipients for this client's email.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/EmailBroadcastRecipientStatus"
          },
          "skipOrFailReason": {
            "type": "string",
            "description": "Why this client was skipped or the send failed. Null when Pending or Sent.",
            "nullable": true,
            "example": "No resolvable To recipients for this client"
          },
          "sentDate": {
            "type": "string",
            "description": "When the email was sent (UTC). Null unless Status is Sent.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single client within an email broadcast with its resolved recipients and delivery status.\nBefore send this is a live pre-send resolution; after send it reflects the stored snapshot."
      },
      "EmailBroadcastRecipientDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailBroadcastRecipientDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "EmailBroadcastRecipientSortField": {
        "enum": [
          "Default"
        ],
        "type": "string",
        "example": "Default"
      },
      "EmailBroadcastRecipientStatus": {
        "enum": [
          "Pending",
          "Sent",
          "Failed",
          "Skipped"
        ],
        "type": "string",
        "example": "Pending"
      },
      "EmailBroadcastRepeatedAddressDto": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "description": "The email address.",
            "nullable": true,
            "example": "emma@apsadvisory.co.uk"
          },
          "clientNames": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The clients it is on, in selection order: the first one keeps it when sending once per address.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One contact address on more than one selected client."
      },
      "EmailBroadcastRepeatedAddressesDto": {
        "type": "object",
        "properties": {
          "addressCount": {
            "type": "integer",
            "description": "How many contact addresses are on more than one selected client.",
            "format": "int32",
            "example": 3
          },
          "duplicateCopyCount": {
            "type": "integer",
            "description": "How many extra copies those addresses would get: the copies sending once per address drops.",
            "format": "int32",
            "example": 7
          },
          "skippedClientCount": {
            "type": "integer",
            "description": "How many clients would send nothing, because every To address already gets the email with an earlier client.",
            "format": "int32",
            "example": 4
          },
          "isPersonalised": {
            "type": "boolean",
            "description": "True when the subject or body uses client-specific merge fields, so each client's copy is\ndifferent and an address sent once only sees the first client's version.",
            "example": true
          },
          "addresses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailBroadcastRepeatedAddressDto"
            },
            "description": "The repeated addresses, most clients first (at most 20).",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Contact addresses that are on more than one of a draft broadcast's clients, and what sending\nonce per address would drop. Team members and the broadcast's fixed addresses are never counted."
      },
      "EmailBroadcastSortField": {
        "enum": [
          "CreatedDate",
          "Status"
        ],
        "type": "string",
        "example": "CreatedDate"
      },
      "EmailBroadcastStatus": {
        "enum": [
          "Draft",
          "Queued",
          "Sending",
          "Completed",
          "Failed",
          "Cancelled",
          "Scheduled"
        ],
        "type": "string",
        "example": "Draft"
      },
      "EmailConfigDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying this email configuration",
            "nullable": true
          },
          "tenantUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "fromEmail": {
            "type": "string",
            "description": "The sender email address for this configuration",
            "nullable": true
          },
          "fromName": {
            "type": "string",
            "description": "The sender display name for this configuration",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether this is the tenant's default email configuration"
          },
          "isSendShared": {
            "type": "boolean",
            "description": "Whether all users in the tenant can send emails from this configuration"
          },
          "readSharing": {
            "$ref": "#/components/schemas/MailboxReadSharing"
          },
          "shareClientEmails": {
            "type": "boolean",
            "description": "With ReadSharing Selected, whether colleagues also see every email with a client (on the\nclient's emails tab and linked tasks). Always false with any other read-sharing."
          },
          "sendEnabled": {
            "type": "boolean",
            "description": "Whether this configuration can send emails (true for SMTP, controlled by OAuth settings for OAuth providers)"
          },
          "readEnabled": {
            "type": "boolean",
            "description": "Whether this configuration can read/sync mailbox emails (only applicable for OAuth providers)"
          },
          "signature": {
            "type": "string",
            "description": "The mailbox's HTML signature: used by everyone who has no personal signature on it, and on\nemails Sodium sends automatically. Only the owner or an admin can change it.",
            "nullable": true
          },
          "quoteOriginalInReplies": {
            "type": "boolean",
            "description": "Whether a reply sent from this mailbox carries the email it answers, quoted, below the reply's text"
          },
          "personalSignature": {
            "type": "string",
            "description": "The current user's own HTML signature on this mailbox, which their composed emails use instead\nof SodiumHQ.DTOs.EmailConfig.EmailConfigDto.Signature; null when they have none.",
            "nullable": true
          },
          "newMailAlert": {
            "$ref": "#/components/schemas/NewMailAlertScope"
          },
          "status": {
            "$ref": "#/components/schemas/ConfigurationStatus"
          },
          "statusReason": {
            "type": "string",
            "description": "User-facing explanation when the configuration is in an error state (e.g. ConnectionError);\nnull when the configuration is healthy. Surface this to the user alongside a reconnect prompt.",
            "nullable": true
          },
          "providerType": {
            "$ref": "#/components/schemas/ProviderType"
          },
          "smtpSettings": {
            "$ref": "#/components/schemas/SmtpSettingsResponseDto"
          },
          "oAuthStatus": {
            "$ref": "#/components/schemas/OAuthStatusResponse"
          },
          "triageEnabled": {
            "type": "boolean",
            "description": "Whether email triage (statuses, assignment and the Matched / Unmatched / Other views) is\nswitched on for this mailbox"
          },
          "triageDefaultStatusCode": {
            "type": "string",
            "description": "The email triage status code new conversations start at",
            "nullable": true
          },
          "triageDefaultAssigneeType": {
            "$ref": "#/components/schemas/EmailTriageAssigneeType"
          },
          "triageDefaultAssigneeUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "triageEnabledFrom": {
            "type": "string",
            "description": "The date triage counts from (UTC): earlier mail is history and shows as done, later mail gets the\nmailbox's defaults. Null while triage is off.",
            "format": "date-time",
            "nullable": true
          },
          "triageTint": {
            "type": "string",
            "description": "The colour the email page tints this mailbox's triage panel, as #RRGGBB; null for none",
            "nullable": true
          },
          "triageAssigneesRestricted": {
            "type": "boolean",
            "description": "Whether only SodiumHQ.DTOs.EmailConfig.EmailConfigDto.TriageAssigneeUserCodes can be assigned the mailbox's conversations;\notherwise everyone who can read it in full can"
          },
          "triageShowServiceStages": {
            "type": "boolean",
            "description": "Whether the email page shows the stages of the matched client's services beside its conversations"
          },
          "triageSummaries": {
            "type": "boolean",
            "description": "Whether the email page shows a summary box on the mailbox's conversations"
          },
          "triageAiSummaries": {
            "type": "boolean",
            "description": "Whether the summary box offers to generate the summary with AI; only takes effect while\nSodiumHQ.DTOs.EmailConfig.EmailConfigDto.TriageSummaries is on"
          },
          "triageAssignOnStatusChange": {
            "type": "boolean",
            "description": "Whether setting the status of an unassigned conversation also assigns it to the person who set it"
          },
          "triageAssigneeUserCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The user codes of the people who can be assigned its conversations, when restricted; null otherwise.\nOnly those who can also read the mailbox count (triage/assignees lists who that is now).",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "Date this configuration was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "Date this configuration was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for an email configuration"
      },
      "EmailConfigDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailConfigDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "EmailConfigSortField": {
        "enum": [
          "FromEmail",
          "CreatedDate"
        ],
        "type": "string",
        "example": "FromEmail"
      },
      "EmailExecutionStateDto": {
        "type": "object",
        "properties": {
          "emailMessageId": {
            "type": "string",
            "description": "The GUID returned by the email service when the email was queued.\nUsed to query delivery status via the email history endpoints.",
            "format": "uuid"
          },
          "sentAt": {
            "type": "string",
            "description": "UTC timestamp of when the email was queued for sending.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Execution state for a SendEmail workflow step.\nContains information about the sent email after execution.\nRead-only - written by the system during step execution, never edited by users."
      },
      "EmailImportance": {
        "enum": [
          "Low",
          "Normal",
          "High"
        ],
        "type": "string",
        "description": "Email importance/priority level",
        "example": "Low"
      },
      "EmailPreviewRecipientDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name of the recipient, if available.",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "Email address of the recipient.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A resolved email recipient for preview display."
      },
      "EmailRecipient": {
        "required": [
          "email"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "maxLength": 256,
            "minLength": 1,
            "type": "string",
            "format": "email"
          }
        },
        "additionalProperties": false
      },
      "EmailRecipientConfig": {
        "type": "object",
        "properties": {
          "includeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include the client's business email (the email address on the client record,\nas opposed to a contact's email address)"
          },
          "contactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types to include (e.g. Main, Billing, Payroll)",
            "nullable": true
          },
          "userTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User role types to include (e.g. ClientManager, ClientPartner).\nTaskOwner is not applicable outside workflow steps.",
            "nullable": true
          },
          "emailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to include",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for resolving email recipients from client contacts, user roles, and static addresses.\nUsed by PCL settings, workflow steps, and any feature that needs configurable email recipients."
      },
      "EmailRecipientDto": {
        "required": [
          "email"
        ],
        "type": "object",
        "properties": {
          "email": {
            "minLength": 1,
            "type": "string",
            "description": "Email address",
            "format": "email"
          },
          "name": {
            "type": "string",
            "description": "Display name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Email recipient DTO"
      },
      "EmailSettingsDto": {
        "type": "object",
        "properties": {
          "emailHeaderContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "emailFooterContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "designTheme": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "replyToEmail": {
            "type": "string",
            "description": "Reply-to email address for system emails",
            "nullable": true
          },
          "replyToName": {
            "type": "string",
            "description": "Reply-to display name for system emails",
            "nullable": true
          },
          "clientEmailSender": {
            "$ref": "#/components/schemas/ClientEmailSender"
          },
          "allowSenderOverride": {
            "type": "boolean",
            "description": "Whether the person sending may choose another mailbox they can send from, where a send screen offers the\nchoice (an HMRC authorisation request, a proposal)."
          }
        },
        "additionalProperties": false,
        "description": "Tenant-level configuration for outbound email branding and sender information.\nControls the visual appearance and sender details for system-generated emails\nsuch as proposal notifications, task assignments, and client communications."
      },
      "EmailSortField": {
        "enum": [
          "CreatedDate",
          "Subject",
          "Status"
        ],
        "type": "string",
        "description": "Specifies the field to sort emails by in list queries",
        "example": "CreatedDate"
      },
      "EmailStatus": {
        "enum": [
          "Queued",
          "Processing",
          "Sent",
          "Failed",
          "Cancelled"
        ],
        "type": "string",
        "description": "Represents the status of an email message",
        "example": "Queued"
      },
      "EmailStepConfigDto": {
        "type": "object",
        "properties": {
          "contentBlockCode": {
            "maxLength": 50,
            "type": "string",
            "description": "Content block code for the email template.\nMust reference an existing Email category content block that defines the subject and body using Liquid syntax.\nMutually exclusive with SubjectLine/BodyHtml — provide one or the other.",
            "nullable": true
          },
          "subjectLine": {
            "maxLength": 500,
            "type": "string",
            "description": "Inline email subject line with Liquid template syntax.\nUse instead of ContentBlockCode for simple emails that don't need a reusable content block.\nMust be provided together with BodyHtml. Mutually exclusive with ContentBlockCode.",
            "nullable": true
          },
          "bodyHtml": {
            "type": "string",
            "description": "Inline email body HTML with Liquid template syntax.\nUse instead of ContentBlockCode for simple emails that don't need a reusable content block.\nMust be provided together with SubjectLine. Mutually exclusive with ContentBlockCode.",
            "nullable": true
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include the client's business email (the email address on the\nclient record) as a To recipient."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for To recipients.\nResolved from the task's client contacts at execution time.",
            "nullable": true
          },
          "recipientUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for To recipients.\nResolved from client team assignments or task ownership at execution time.\nNote: SpecificUser is not applicable for email recipients.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses for To recipients.\nUse for external recipients or email addresses not in the system.",
            "nullable": true
          },
          "ccIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include the client's business email as a CC recipient."
          },
          "ccContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for CC recipients.",
            "nullable": true
          },
          "ccUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for CC recipients.\nNote: SpecificUser is not applicable for email recipients.",
            "nullable": true
          },
          "ccEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses for CC recipients.",
            "nullable": true
          },
          "bccIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include the client's business email as a BCC recipient."
          },
          "bccContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for BCC recipients.",
            "nullable": true
          },
          "bccUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for BCC recipients.\nNote: SpecificUser is not applicable for email recipients.",
            "nullable": true
          },
          "bccEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses for BCC recipients.",
            "nullable": true
          },
          "attachments": {
            "maxItems": 10,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Practice documents (code + name) attached to the email on every send.\nAuto-executed steps attach them automatically; the manual compose dialog\npre-seeds them as removable attachments. Maximum 10 attachments,\ncombined size up to 15MB (validated on save).",
            "nullable": true
          },
          "senderSource": {
            "$ref": "#/components/schemas/WorkflowEmailSenderSource"
          },
          "senderMailboxCode": {
            "maxLength": 50,
            "type": "string",
            "description": "The email connection to send from when SenderSource is SpecificMailbox. Ignored otherwise,\nand required when SenderSource is SpecificMailbox.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for SendEmail workflow steps.\nUsed for both workflow template definition and task workflow step instance customization.\nAll properties must be provided when creating or updating."
      },
      "EmailSummaryDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique message identifier",
            "format": "uuid"
          },
          "tenantCode": {
            "type": "string",
            "description": "Tenant code the email belongs to",
            "nullable": true
          },
          "subject": {
            "type": "string",
            "description": "Email subject line",
            "nullable": true
          },
          "recipientEmail": {
            "type": "string",
            "description": "Primary recipient email address (first To recipient)",
            "nullable": true
          },
          "recipientName": {
            "type": "string",
            "description": "Primary recipient display name (first To recipient)",
            "nullable": true
          },
          "fromEmail": {
            "type": "string",
            "description": "Sender email address",
            "nullable": true
          },
          "fromName": {
            "type": "string",
            "description": "Sender display name",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/EmailStatus"
          },
          "lastError": {
            "type": "string",
            "description": "Last error message if the email failed",
            "nullable": true
          },
          "metadata": {
            "type": "string",
            "description": "JSON metadata associated with the email",
            "nullable": true
          },
          "externalReference": {
            "type": "string",
            "description": "External reference from the calling application",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the email was created",
            "format": "date-time"
          },
          "sentAt": {
            "type": "string",
            "description": "When the email was sent (null if not yet sent)",
            "format": "date-time",
            "nullable": true
          },
          "retryCount": {
            "type": "integer",
            "description": "Number of retry attempts made",
            "format": "int32"
          },
          "maxRetryCount": {
            "type": "integer",
            "description": "Maximum number of retry attempts allowed",
            "format": "int32"
          },
          "nextRetryAt": {
            "type": "string",
            "description": "When the next send attempt is due (retry or rate-limit deferral); null when none is scheduled",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Lightweight email summary for list responses"
      },
      "EmailTriageAssigneeType": {
        "enum": [
          "Unassigned",
          "SpecificUser",
          "ClientManager",
          "ClientPartner",
          "ClientAssociate",
          "RecipientUser"
        ],
        "type": "string",
        "example": "Unassigned"
      },
      "EmailTriageHeaderWidgetDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The widget's unique code",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "The widget's heading; null for a widget shown without one",
            "nullable": true
          },
          "configJson": {
            "type": "string",
            "description": "The widget's settings as JSON, in the web app's own shape (the dashboard widget's config)",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position across the top of the email page",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One of the practice's header widgets on the email page: count boxes per person or per status, shown\nacross the top of the page for everyone"
      },
      "EmailTriageHeaderWidgetDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailTriageHeaderWidgetDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "EmailTriageHeaderWidgetSortField": {
        "enum": [
          "SortOrder",
          "Title"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "EmailTriageStatusDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this status, as the conversations store it",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name, e.g. \"Waiting on client\"",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position in the status picker",
            "format": "int32"
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the status is offered when setting a conversation's status"
          },
          "color": {
            "type": "string",
            "description": "Display colour, e.g. \"#3B82F6\"",
            "nullable": true
          },
          "isDone": {
            "type": "boolean",
            "description": "Whether the status closes a conversation"
          },
          "archiveOnDone": {
            "type": "boolean",
            "description": "Whether setting this status also archives the conversation in Outlook or Gmail (Done statuses only)"
          },
          "archiveFolderName": {
            "type": "string",
            "description": "With ArchiveOnDone: the folder path (Gmail: label name) the conversation moves to in each mailbox that has it;\nnull for the mailbox's archive",
            "nullable": true
          },
          "offerOnSend": {
            "type": "boolean",
            "description": "Whether the reply Send button offers this status (\"Send & Done\"). Any status may be offered."
          },
          "onReplyStatusCode": {
            "type": "string",
            "description": "The status a client's reply moves the conversation to. Null: back to the mailbox's default status\nfor a Done status, no move for an open one. A Done status's own code keeps it Done.",
            "nullable": true
          },
          "bringBackEnabled": {
            "type": "boolean",
            "description": "Whether setting this status also sets a bring back: after SodiumHQ.DTOs.EmailTriage.EmailTriageStatusDto.BringBackDays the conversation moves to\nSodiumHQ.DTOs.EmailTriage.EmailTriageStatusDto.BringBackStatusCode, if nothing has changed its status by then"
          },
          "bringBackDays": {
            "type": "integer",
            "description": "The default number of days before the conversation is brought back; null when Bring back is off",
            "format": "int32",
            "nullable": true
          },
          "bringBackStatusCode": {
            "type": "string",
            "description": "The default status to bring the conversation back to; null when Bring back is off",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A status an email conversation can have in a mailbox with triage switched on. Tenant-configurable;\nseeded with New, In progress, Waiting on client, Done and Snooze."
      },
      "EmailTriageStatusDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailTriageStatusDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "EmailTriageStatusSortField": {
        "enum": [
          "SortOrder",
          "Name"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "EmailTriageUserDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The tenant user's code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The user's display name, or their email when they have not set one",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The user's sign-in email address",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A user who can read a mailbox in full, so can be assigned its conversations and mentioned in its comments"
      },
      "EmploymentDeductionItem": {
        "type": "object",
        "properties": {
          "customerReference": {
            "type": "string",
            "nullable": true
          },
          "amountDeducted": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EmploymentDeductions": {
        "type": "object",
        "properties": {
          "studentLoans": {
            "$ref": "#/components/schemas/StudentLoanDeductions"
          }
        },
        "additionalProperties": false
      },
      "EmploymentDetails": {
        "type": "object",
        "properties": {
          "employerRef": {
            "type": "string",
            "nullable": true
          },
          "employerName": {
            "type": "string",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "cessationDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "payrollId": {
            "type": "string",
            "nullable": true
          },
          "occupationalPension": {
            "type": "boolean",
            "nullable": true
          },
          "dateIgnored": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EmploymentEmployer": {
        "type": "object",
        "properties": {
          "employerRef": {
            "type": "string",
            "nullable": true
          },
          "employerName": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EmploymentFinancialDetail": {
        "type": "object",
        "properties": {
          "employmentSequenceNumber": {
            "type": "string",
            "nullable": true
          },
          "payrollId": {
            "type": "string",
            "nullable": true
          },
          "companyDirector": {
            "type": "boolean",
            "nullable": true
          },
          "closeCompany": {
            "type": "boolean",
            "nullable": true
          },
          "directorshipCeasedDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "cessationDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "occupationalPension": {
            "type": "boolean",
            "nullable": true
          },
          "disguisedRemuneration": {
            "type": "boolean",
            "nullable": true
          },
          "offPayrollWorker": {
            "type": "boolean",
            "nullable": true
          },
          "employer": {
            "$ref": "#/components/schemas/EmploymentEmployer"
          },
          "pay": {
            "$ref": "#/components/schemas/EmploymentPay"
          },
          "customerEstimatedPay": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "deductions": {
            "$ref": "#/components/schemas/EmploymentDeductions"
          },
          "benefitsInKind": {
            "$ref": "#/components/schemas/BenefitsInKind"
          }
        },
        "additionalProperties": false
      },
      "EmploymentFinancialDetails": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "source": {
            "type": "string",
            "nullable": true
          },
          "customerAdded": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "dateIgnored": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "employment": {
            "$ref": "#/components/schemas/EmploymentFinancialDetail"
          }
        },
        "additionalProperties": false
      },
      "EmploymentListItem": {
        "type": "object",
        "properties": {
          "employmentId": {
            "type": "string",
            "nullable": true
          },
          "employerName": {
            "type": "string",
            "nullable": true
          },
          "dateIgnored": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EmploymentLumpSums": {
        "type": "object",
        "properties": {
          "employerName": {
            "type": "string",
            "nullable": true
          },
          "employerRef": {
            "type": "string",
            "nullable": true
          },
          "taxableLumpSumsAndCertainIncome": {
            "$ref": "#/components/schemas/LumpSumAmount"
          },
          "benefitFromEmployerFinancedRetirementScheme": {
            "$ref": "#/components/schemas/RetirementSchemeBenefit"
          },
          "redundancyCompensationPaymentsOverExemption": {
            "$ref": "#/components/schemas/LumpSumAmount"
          },
          "redundancyCompensationPaymentsUnderExemption": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EmploymentPay": {
        "type": "object",
        "properties": {
          "taxablePayToDate": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalTaxToDate": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "payFrequency": {
            "type": "string",
            "nullable": true
          },
          "paymentDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "taxWeekNo": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "taxMonthNo": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EmploymentPayInput": {
        "type": "object",
        "properties": {
          "taxablePayToDate": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalTaxToDate": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EmploymentsList": {
        "type": "object",
        "properties": {
          "employments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmploymentListItem"
            },
            "nullable": true
          },
          "customEmployments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmploymentListItem"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EngagementAcceptanceStepStatusDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Step identifier: \"directDebit\", \"aml\", or \"dataForm:{form code}\".",
            "nullable": true
          },
          "label": {
            "type": "string",
            "description": "What the step is: \"Direct Debit\", \"Identity verification\", or the form's name.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/AcceptanceStepStatus"
          }
        },
        "additionalProperties": false,
        "description": "One step an accepted proposal asked the client to complete, and whether they have, as the practice sees it."
      },
      "EngagementAcceptanceUrlDto": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Absolute URL on the tenant's client portal subdomain, e.g. https://acme.sodiumportal.com/proposal/{guid}",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The client portal URL at which an engagement's acceptance flow is hosted."
      },
      "EngagementDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "guid": {
            "type": "string",
            "description": "Unique identifier for this engagement",
            "format": "uuid"
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "date": {
            "type": "string",
            "description": "Date of the engagement",
            "format": "date"
          },
          "status": {
            "$ref": "#/components/schemas/EngagementStatus"
          },
          "type": {
            "$ref": "#/components/schemas/EngagementType"
          },
          "typeName": {
            "type": "string",
            "description": "Display name for the engagement type (\"Proposal\" or \"Engagement Letter\")",
            "nullable": true,
            "readOnly": true
          },
          "recipientFirstName": {
            "type": "string",
            "description": "First name of the recipient for this engagement",
            "nullable": true
          },
          "recipientLastName": {
            "type": "string",
            "description": "Last name of the recipient for this engagement",
            "nullable": true
          },
          "recipientEmail": {
            "type": "string",
            "description": "Email address of the recipient for this engagement",
            "nullable": true
          },
          "requestDdMandate": {
            "type": "boolean",
            "description": "Per-proposal override for the \"set up Direct Debit\" acceptance step.\nNull means the practice default (from proposal settings) applies.",
            "nullable": true
          },
          "requestAmlOnboarding": {
            "type": "boolean",
            "description": "Per-proposal override for the identity-verification (AML) acceptance step.\nNull means the practice default (from proposal settings) applies.",
            "nullable": true
          },
          "showPricingSummary": {
            "type": "boolean",
            "description": "Per-proposal override for showing the pricing summary panel on the acceptance page.\nNull means the practice default (from proposal settings) applies.",
            "nullable": true
          },
          "excludedDataFormCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the forms configured in proposal settings that this proposal opts out of.\nEmpty means every configured form applies.",
            "nullable": true
          },
          "customTokenValues": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The custom token values entered when the documents were last generated, keyed as the template's\ntoken list names them (e.g. \"Custom.FeeNotes\"). Empty when none were asked for.",
            "nullable": true
          },
          "hasProposalPdf": {
            "type": "boolean",
            "description": "Indicates whether a proposal PDF has been uploaded"
          },
          "hasLofEPdf": {
            "type": "boolean",
            "description": "Indicates whether a letter of engagement PDF has been uploaded"
          },
          "proposalTemplate": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "lofETemplate": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "acceptance": {
            "$ref": "#/components/schemas/AcceptanceDto"
          },
          "lastViewed": {
            "type": "string",
            "description": "Date and time when the engagement was last viewed",
            "format": "date-time",
            "nullable": true
          },
          "totalValue": {
            "type": "number",
            "description": "Total value of all services in this engagement (annualised recurring + one-off fees)",
            "format": "double"
          },
          "weeklyTotal": {
            "type": "number",
            "description": "Sum of weekly service prices (per-week amount, not annualised)",
            "format": "double"
          },
          "monthlyTotal": {
            "type": "number",
            "description": "Sum of monthly service prices (per-month amount, not annualised)",
            "format": "double"
          },
          "quarterlyTotal": {
            "type": "number",
            "description": "Sum of quarterly service prices (per-quarter amount)",
            "format": "double"
          },
          "annualTotal": {
            "type": "number",
            "description": "Sum of annual service prices",
            "format": "double"
          },
          "oneOffTotal": {
            "type": "number",
            "description": "Sum of one-off service prices",
            "format": "double"
          },
          "catchUpTotal": {
            "type": "number",
            "description": "Sum of the catch-up fees across the engagement's services. Not part of OneOffTotal: shown as\nits own line under the practice's catch-up fee label. Counted in TotalValue.",
            "format": "double"
          },
          "numberOfServices": {
            "type": "integer",
            "description": "Number of services included in this engagement",
            "format": "int32"
          },
          "proposalServices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientBillableServiceDto"
            },
            "description": "List of services included in this engagement.\nThese are historical snapshots of ClientBillableServices at the time of engagement creation.\nThe original ClientBillableServices may have been modified or deleted since this engagement was created.",
            "nullable": true
          },
          "proposalPdfUrl": {
            "type": "string",
            "description": "Signed URL for streaming the proposal PDF without authentication.\nOnly populated when HasProposalPdf is true.",
            "nullable": true
          },
          "lofEPdfUrl": {
            "type": "string",
            "description": "Signed URL for streaming the letter of engagement PDF without authentication.\nOnly populated when HasLofEPdf is true.",
            "nullable": true
          },
          "link": {
            "type": "string",
            "description": "Public link for accepting this engagement, on the tenant's client portal.\nFormat: {ClientPortal.BaseUrl for the tenant}/proposal/{Guid}\nThis is a computed property and is not persisted in the database.\nNull when the tenant code isn't loaded on the engagement.",
            "nullable": true
          },
          "scheduledSendCode": {
            "type": "string",
            "description": "Code of the email scheduled to send this proposal later, while it waits to go out. Null when\nnothing is scheduled. The proposal keeps its status until the email is sent.",
            "nullable": true
          },
          "scheduledSendAt": {
            "type": "string",
            "description": "When the scheduled email is due to go out (UTC). Null when nothing is scheduled.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for engagement information"
      },
      "EngagementDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EngagementDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "EngagementEmailDto": {
        "type": "object",
        "properties": {
          "messageId": {
            "type": "string",
            "description": "The message ID from the email service",
            "format": "uuid"
          },
          "sentDate": {
            "type": "string",
            "description": "The date when the email was sent",
            "format": "date-time"
          },
          "subject": {
            "type": "string",
            "description": "The email subject line",
            "nullable": true
          },
          "toRecipients": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of recipient email addresses",
            "nullable": true
          },
          "status": {
            "type": "string",
            "description": "The status of the email (e.g., Sent, Delivered, Failed)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents an email sent for an engagement"
      },
      "EngagementSettingsDataFormDto": {
        "type": "object",
        "properties": {
          "dataFormCode": {
            "type": "string",
            "description": "Code of the form to present. Only published forms can be used.",
            "nullable": true
          },
          "dataFormName": {
            "type": "string",
            "description": "Name of the form",
            "nullable": true
          },
          "stepTitle": {
            "type": "string",
            "description": "The label shown for this step in the progress bar at the top of the acceptance flow",
            "nullable": true
          },
          "stepDescription": {
            "type": "string",
            "description": "Short text shown under the step label in the progress bar",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position of this form among the form steps. Lower sorts first.",
            "format": "int32"
          },
          "isSkippable": {
            "type": "boolean",
            "description": "Whether the client can move past this step without completing the form"
          }
        },
        "additionalProperties": false,
        "description": "A form presented as a step in the proposal acceptance flow."
      },
      "EngagementSettingsDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier for the settings",
            "nullable": true
          },
          "introContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "thankYouContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "emailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "acceptanceTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "notifyClientManagerOnAcceptance": {
            "type": "boolean",
            "description": "Whether to send an email notification to the client manager when an engagement is accepted"
          },
          "notifyPartnerOnAcceptance": {
            "type": "boolean",
            "description": "Whether to send an email notification to the partner when an engagement is accepted"
          },
          "designTheme": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "showPracticeName": {
            "type": "boolean",
            "description": "Whether to display the practice name on engagement acceptance pages and documents"
          },
          "showPricingSummary": {
            "type": "boolean",
            "description": "Whether to show the pricing summary panel on the proposal acceptance page"
          },
          "catchUpFeeLabel": {
            "type": "string",
            "description": "How the practice names a catch-up fee wherever one is shown (costs table, billing lines,\nproposal editor, acceptance summary). Defaults to \"Catch-up fee\".",
            "nullable": true
          },
          "attachPDFs": {
            "type": "boolean",
            "description": "Whether to attach engagement PDFs to the engagement email"
          },
          "thankYouEmailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "requestDdMandate": {
            "type": "boolean",
            "description": "Whether to request a Direct Debit mandate when engagement is accepted"
          },
          "requestAmlOnboarding": {
            "type": "boolean",
            "description": "Whether to request AML onboarding for the main contact when engagement is accepted"
          },
          "amlOnboardingLevelId": {
            "type": "string",
            "description": "The AML platform onboarding level ID to use when creating the onboarding request",
            "nullable": true
          },
          "signaturePageContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "useThirdPartyProposalPlatform": {
            "type": "boolean",
            "description": "Whether to use a third-party platform (e.g., Socket) for proposals instead of native Sodium proposals"
          },
          "addToPipelineOnSend": {
            "type": "boolean",
            "description": "Whether to add the client to a sales pipeline when their proposal is first sent"
          },
          "onSendPipeline": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "dataForms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EngagementSettingsDataFormDto"
            },
            "description": "Forms presented as steps in the acceptance flow, in the order they appear",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Tenant-level configuration for engagement behavior, branding, and notification settings.\nControls how engagements are presented to clients, what happens when they're accepted,\nand how engagement emails are formatted and delivered."
      },
      "EngagementSortField": {
        "enum": [
          "Client",
          "Code",
          "Date",
          "Status",
          "NumberOfServices",
          "TotalValue"
        ],
        "type": "string",
        "example": "Client"
      },
      "EngagementStatus": {
        "enum": [
          "Unsent",
          "Sent",
          "Viewed",
          "Accepted",
          "Rejected"
        ],
        "type": "string",
        "example": "Unsent"
      },
      "EngagementSummaryDto": {
        "type": "object",
        "properties": {
          "unsent": {
            "type": "integer",
            "description": "Count of engagements that have not been sent",
            "format": "int32"
          },
          "sent": {
            "type": "integer",
            "description": "Count of engagements that have been sent",
            "format": "int32"
          },
          "viewed": {
            "type": "integer",
            "description": "Count of engagements that have been viewed",
            "format": "int32"
          },
          "accepted": {
            "type": "integer",
            "description": "Count of engagements that have been accepted",
            "format": "int32"
          },
          "rejected": {
            "type": "integer",
            "description": "Count of engagements that have been rejected",
            "format": "int32"
          },
          "total": {
            "type": "integer",
            "description": "Total count of all engagements",
            "format": "int32",
            "readOnly": true
          },
          "unsentTotalValue": {
            "type": "number",
            "description": "Sum of total value for unsent engagements",
            "format": "double"
          },
          "sentTotalValue": {
            "type": "number",
            "description": "Sum of total value for sent engagements",
            "format": "double"
          },
          "viewedTotalValue": {
            "type": "number",
            "description": "Sum of total value for viewed engagements",
            "format": "double"
          },
          "acceptedTotalValue": {
            "type": "number",
            "description": "Sum of total value for accepted engagements",
            "format": "double"
          },
          "rejectedTotalValue": {
            "type": "number",
            "description": "Sum of total value for rejected engagements",
            "format": "double"
          },
          "overallTotalValue": {
            "type": "number",
            "description": "Total value across all engagements",
            "format": "double",
            "readOnly": true
          }
        },
        "additionalProperties": false,
        "description": "Summary of engagements grouped by status, including counts and total values"
      },
      "EngagementType": {
        "enum": [
          "ProposalAndEngagementLetter",
          "EngagementLetter"
        ],
        "type": "string",
        "example": "ProposalAndEngagementLetter"
      },
      "EntityTagHeaderValue": {
        "type": "object",
        "properties": {
          "tag": {
            "$ref": "#/components/schemas/StringSegment"
          },
          "isWeak": {
            "type": "boolean",
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "EnumMetadata": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "value": {
            "type": "integer",
            "format": "int32"
          },
          "displayName": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "icon": {
            "type": "string",
            "nullable": true
          },
          "backgroundColor": {
            "type": "string",
            "nullable": true
          },
          "textColor": {
            "type": "string",
            "nullable": true
          },
          "group": {
            "type": "string",
            "nullable": true
          },
          "order": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "logoUrl": {
            "type": "string",
            "nullable": true
          },
          "product": {
            "type": "string",
            "nullable": true
          },
          "fontFamily": {
            "type": "string",
            "nullable": true
          },
          "fontFallback": {
            "type": "string",
            "nullable": true
          },
          "googleFontUrl": {
            "type": "string",
            "nullable": true
          },
          "isOnlineOnly": {
            "type": "boolean",
            "nullable": true
          },
          "hmrcService": {
            "type": "string",
            "nullable": true
          },
          "hmrcClientIdType": {
            "type": "string",
            "nullable": true
          },
          "hmrcClientIdSource": {
            "type": "string",
            "nullable": true
          },
          "hmrcKnownFactSource": {
            "type": "string",
            "nullable": true
          },
          "hmrcFlowType": {
            "type": "string",
            "nullable": true
          },
          "percentage": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "isDataFormSupported": {
            "type": "boolean",
            "nullable": true
          },
          "dataFormDataType": {
            "type": "string",
            "nullable": true
          },
          "dataFormAlwaysHasValue": {
            "type": "boolean",
            "nullable": true
          },
          "dataFormOptions": {
            "type": "string",
            "nullable": true
          },
          "isWorkflowStepOnly": {
            "type": "boolean",
            "nullable": true
          },
          "hasOptions": {
            "type": "boolean",
            "nullable": true
          },
          "hasMaxLength": {
            "type": "boolean",
            "nullable": true
          },
          "hasLines": {
            "type": "boolean",
            "nullable": true
          },
          "hasDisplayWidth": {
            "type": "boolean",
            "nullable": true
          },
          "hasFullRow": {
            "type": "boolean",
            "nullable": true
          },
          "hasBooleanDisplayMode": {
            "type": "boolean",
            "nullable": true
          },
          "hasAllowedExtensions": {
            "type": "boolean",
            "nullable": true
          },
          "hasNumberFormat": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExecuteWorkflowStepRequest": {
        "type": "object",
        "properties": {
          "documentCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of existing client documents to link to the step. A Document Approval step can\ncover several documents; an Upload a Document step takes exactly one.\nEach document must have a ClientApprovalStatus of None or Pending.\nWhen omitted, the step must have a documentTemplateCode configured — the document will be generated asynchronously.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Optional request body for executing a workflow step.\nFor document steps: provide documentCodes to link existing documents (manually uploaded or pre-generated from template).\nOmit documentCodes to trigger async generation from the step's configured template.\nIgnored for other step types."
      },
      "ExpectedTimeDayDto": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "The date the expectation applies to",
            "format": "date"
          },
          "isWorkingDay": {
            "type": "boolean",
            "description": "True when the member's working pattern expects time on this date — so an empty day\nthey were meant to work reads differently from a day they never work. Bank holidays\nare never working days"
          },
          "expectedMinutes": {
            "type": "integer",
            "description": "Minutes the member's pattern expects on this date — zero on non-working days, bank\nholidays, or when there is no pattern",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One day's expectation within an expected-time window"
      },
      "ExpectedTimeDto": {
        "type": "object",
        "properties": {
          "workingPattern": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "hasOwnPattern": {
            "type": "boolean",
            "description": "True when the member is on a working pattern of their own rather than the practice\ndefault"
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExpectedTimeDayDto"
            },
            "description": "One entry per day of the requested window, oldest first",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a team member's working pattern expects of them over a date window, day by day.\nBacks the Time calendar's daily targets. Expectations come from the member's own\npattern, falling back to the practice default; when the practice has no patterns at\nall, WorkingPattern is null and every day reads as zero expectation."
      },
      "ExternalCalendarEventDto": {
        "type": "object",
        "properties": {
          "subscriptionCode": {
            "type": "string",
            "description": "Code of the subscription the event came from — join to the subscription list for the\ncalendar's name and colour.",
            "nullable": true
          },
          "uid": {
            "type": "string",
            "description": "The source event's UID plus the occurrence date — stable across fetches.",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "The event's summary line.",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "The day the occurrence starts, in practice wall-clock time.",
            "format": "date"
          },
          "startTime": {
            "type": "string",
            "description": "Start time on the start day. Null for all-day events.",
            "format": "time",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "For an all-day event, the last day it covers (inclusive — a one-day event has\nEndDate equal to StartDate). For a timed event, the day it ends on.",
            "format": "date"
          },
          "endTime": {
            "type": "string",
            "description": "End time on the end day. Null for all-day events; equals StartTime for events with no\nstated end.",
            "format": "time",
            "nullable": true
          },
          "isAllDay": {
            "type": "boolean",
            "description": "Whether this is an all-day (date-only) event."
          },
          "location": {
            "type": "string",
            "description": "The event's location line, when the feed provides one.",
            "nullable": true
          },
          "meetingUrl": {
            "type": "string",
            "description": "Video-call link (Google Meet, Teams, Zoom), when the feed carries one.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The event's description as plain text, capped server-side. Google Meet's boilerplate\nblock is stripped — its join link surfaces as MeetingUrl instead.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One concrete occurrence from an external calendar subscription, with recurrences already\nexpanded and times in practice wall-clock (Europe/London) so they line up with task times.\nWall-clock values are date + time pairs, matching how tasks carry StartDate/StartTime."
      },
      "ExternalDocumentDto": {
        "type": "object",
        "properties": {
          "externalFileId": {
            "type": "string",
            "description": "The platform-specific file identifier",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "description": "File name from the external platform",
            "nullable": true
          },
          "fileSize": {
            "type": "integer",
            "description": "File size in bytes",
            "format": "int64"
          },
          "modifiedDate": {
            "type": "string",
            "description": "Last modified date from the external platform",
            "format": "date-time",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "description": "URL to open/download the file from the provider",
            "nullable": true
          },
          "isFolder": {
            "type": "boolean",
            "description": "Whether this file is tracked in our system. When false, the fields below\n(Code, Title, Category, ReviewStatus, etc.) will be null."
          },
          "isTracked": {
            "type": "boolean"
          },
          "code": {
            "type": "string",
            "description": "Our internal document code (null for untracked files)",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "Document title (null for untracked files)",
            "nullable": true
          },
          "summary": {
            "type": "string",
            "description": "Document summary (null for untracked files)",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "Document date (null for untracked files)",
            "format": "date",
            "nullable": true
          },
          "category": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "reviewStatus": {
            "$ref": "#/components/schemas/ReviewStatus"
          },
          "clientApprovalStatus": {
            "$ref": "#/components/schemas/ClientApprovalStatus"
          },
          "visibleInClientPortal": {
            "type": "boolean",
            "description": "Whether this document is visible in the client portal (null for untracked files)",
            "nullable": true
          },
          "uploadedByContact": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "downloadUrl": {
            "type": "string",
            "description": "Signed download URL via our streaming endpoint (null for untracked files)",
            "nullable": true
          },
          "documentRequest": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "portalFolderPath": {
            "type": "string",
            "description": "Where the document appears in the client portal (null for untracked files, and for\ntracked documents sitting at the portal root). Independent of the physical folder.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the document was created in our system (null for untracked files)",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A file from the external storage provider, enriched with metadata from our DB\nwhen the file is tracked. Untracked files (uploaded outside Sodium) have null\nfor DB-sourced fields like Code, Category, ReviewStatus, etc."
      },
      "ExternalDocumentDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalDocumentDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ExternalFileMoveResultDto": {
        "type": "object",
        "properties": {
          "externalFileId": {
            "type": "string",
            "description": "The identifier the caller sent, so it can match this result to the file.",
            "nullable": true
          },
          "newExternalFileId": {
            "type": "string",
            "description": "The identifier after the move. Differs from the original only on platforms that identify\nfiles by path — callers holding the old value should replace it with this one.",
            "nullable": true
          },
          "success": {
            "type": "boolean",
            "description": "Whether the file was moved."
          },
          "error": {
            "type": "string",
            "description": "Why the move failed. Null when it succeeded.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of moving a single file within a batch move."
      },
      "ExternalFolderReferenceDto": {
        "type": "object",
        "properties": {
          "containerId": {
            "type": "string",
            "description": "Provider-specific identifier for the folder/container",
            "nullable": true
          },
          "driveId": {
            "type": "string",
            "description": "Provider-specific drive identifier (null when not applicable)",
            "nullable": true
          },
          "siteId": {
            "type": "string",
            "description": "Provider-specific site identifier (null when not applicable)",
            "nullable": true
          },
          "displayPath": {
            "type": "string",
            "description": "Human-readable path for display in the UI",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "description": "URL to open this folder in the provider's web UI",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for an external folder reference"
      },
      "ExternalMailboxEmailDetailResponse": {
        "type": "object",
        "properties": {
          "uniqueId": {
            "type": "string",
            "description": "Unique identifier for this email",
            "format": "uuid"
          },
          "direction": {
            "$ref": "#/components/schemas/MailboxEmailDirection"
          },
          "subject": {
            "type": "string",
            "description": "Email subject",
            "nullable": true
          },
          "fromEmail": {
            "type": "string",
            "description": "Sender email address",
            "nullable": true
          },
          "fromName": {
            "type": "string",
            "description": "Sender display name",
            "nullable": true
          },
          "htmlBody": {
            "type": "string",
            "description": "HTML body of the email",
            "nullable": true
          },
          "plainTextBody": {
            "type": "string",
            "description": "Plain text body of the email",
            "nullable": true
          },
          "messageDate": {
            "type": "string",
            "description": "When the email was received or sent",
            "format": "date-time"
          },
          "toRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "To recipients",
            "nullable": true
          },
          "ccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "CC recipients",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MailboxAttachmentDto"
            },
            "description": "Attachment metadata",
            "nullable": true
          },
          "conversationId": {
            "type": "string",
            "description": "Conversation ID for grouping messages into threads",
            "nullable": true
          },
          "reconnectRequired": {
            "type": "boolean",
            "description": "Whether the user needs to reconnect their mailbox to view this email"
          },
          "notFound": {
            "type": "boolean",
            "description": "True when this was a draft whose provider copy no longer exists (already sent or deleted\ndirectly in the mailbox). The stale local row has already been removed — the caller should\ndrop it from any visible list rather than trying to display or edit it."
          },
          "conversationLinks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConversationLinkDto"
            },
            "description": "The links on the message's conversation, as the list conversation links endpoint returns\nthem. Only filled when the message was fetched with includeLinks=true; null otherwise, and\nnull when the message has no conversation or was not found.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Full email detail response with body content fetched on-demand from the provider"
      },
      "ExternalMailboxEmailSummaryDto": {
        "type": "object",
        "properties": {
          "uniqueId": {
            "type": "string",
            "description": "Unique identifier for this email",
            "format": "uuid"
          },
          "subject": {
            "type": "string",
            "description": "Email subject",
            "nullable": true
          },
          "fromEmail": {
            "type": "string",
            "description": "Sender email address",
            "nullable": true
          },
          "fromName": {
            "type": "string",
            "description": "Sender display name",
            "nullable": true
          },
          "snippet": {
            "type": "string",
            "description": "Body preview snippet",
            "nullable": true
          },
          "messageDate": {
            "type": "string",
            "description": "When the email was received or sent",
            "format": "date-time"
          },
          "isRead": {
            "type": "boolean",
            "description": "Whether the email has been read"
          },
          "hasAttachments": {
            "type": "boolean",
            "description": "Whether the email has attachments"
          },
          "importance": {
            "$ref": "#/components/schemas/EmailImportance"
          },
          "conversationId": {
            "type": "string",
            "description": "Conversation ID for grouping messages into threads",
            "nullable": true
          },
          "configCode": {
            "type": "string",
            "description": "Configuration code (GUID) identifying which mailbox this email belongs to",
            "nullable": true
          },
          "folders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Folders/labels this email currently belongs to. For Outlook this is exactly one entry;\nfor Gmail an email can belong to many labels. Each entry's `Code` is the folder's\nUniqueId and `Name` is the display path.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Summary DTO for a mailbox email (used in list views)"
      },
      "ExternalMailboxEmailSummaryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalMailboxEmailSummaryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ExternalMailboxFolderDto": {
        "type": "object",
        "properties": {
          "uniqueId": {
            "type": "string",
            "description": "Folder UniqueId (Guid) — stable identifier suitable for URL routing and filter params.",
            "format": "uuid"
          },
          "configCode": {
            "type": "string",
            "description": "Configuration UniqueId (Guid) the folder belongs to. Lets the UI group the response\nper-mailbox or filter to a single mailbox client-side.",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "Display name of the folder/label (e.g. \"Inbox\", \"Clients/Acme\").",
            "nullable": true
          },
          "path": {
            "type": "string",
            "description": "Provider-canonical path. For Outlook this is the full folder path\n(e.g. \"Inbox/Sub\"); for Gmail this is the label name (e.g. \"Clients/Acme\")\nwhere forward slashes denote hierarchy.",
            "nullable": true
          },
          "systemFolderType": {
            "$ref": "#/components/schemas/SystemFolderType"
          },
          "parentFolderUniqueId": {
            "type": "string",
            "description": "UniqueId of the parent folder, or null for top-level folders. Used to render Outlook\nfolder hierarchies. Gmail labels do not use this — hierarchy is encoded in Path.",
            "format": "uuid",
            "nullable": true
          },
          "isSystem": {
            "type": "boolean",
            "description": "True if the folder is provider-system (Inbox, Sent, etc.) rather than user-created."
          },
          "totalCount": {
            "type": "integer",
            "description": "Total number of emails currently mapped to this folder (junction row count).",
            "format": "int32"
          },
          "unreadCount": {
            "type": "integer",
            "description": "Number of unread emails currently mapped to this folder.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One folder (Outlook) or label (Gmail) belonging to a mailbox configuration.\nReturned by the tenant-scoped folders endpoint so the UI can render a folder/label\ntree across every accessible read-enabled configuration."
      },
      "ExternalMeetingNoteAttendeeDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One person at an external meeting"
      },
      "ExternalMeetingNoteDetailDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this note",
            "nullable": true
          },
          "externalPlatform": {
            "type": "string",
            "description": "The note taker's platform key, e.g. \"Granola\"",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ExternalMeetingNoteStatus"
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "When the meeting started (UTC)",
            "format": "date-time"
          },
          "attendees": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalMeetingNoteAttendeeDto"
            },
            "description": "The people at the meeting. Empty for a Matched note, whose meeting lists its own attendees, and for a note ignored by deleting its imported meeting note.",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "description": "The note on the platform's own site",
            "nullable": true
          },
          "suggestedClients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The clients the attendees matched, when more than one did; offered first when filing",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The client the note is on, when its status is Matched; null otherwise",
            "nullable": true
          },
          "taskCode": {
            "type": "string",
            "description": "The client's task the note is linked to, when its status is Matched; null otherwise",
            "nullable": true
          },
          "ignoredDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "endTime": {
            "type": "string",
            "description": "When the meeting ended (UTC)",
            "format": "date-time",
            "nullable": true
          },
          "summary": {
            "type": "string",
            "description": "The summary as HTML; null when the note taker has none, or no longer has the note",
            "nullable": true
          },
          "content": {
            "type": "string",
            "description": "The transcript as HTML; null when the note taker has none, or the connection does not import transcripts",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An unmatched or ignored meeting note with its summary, and its transcript if the connection imports them, fetched from the note taker for review\nbefore it is filed or ignored"
      },
      "ExternalMeetingNoteDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this note",
            "nullable": true
          },
          "externalPlatform": {
            "type": "string",
            "description": "The note taker's platform key, e.g. \"Granola\"",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ExternalMeetingNoteStatus"
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "When the meeting started (UTC)",
            "format": "date-time"
          },
          "attendees": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalMeetingNoteAttendeeDto"
            },
            "description": "The people at the meeting. Empty for a Matched note, whose meeting lists its own attendees, and for a note ignored by deleting its imported meeting note.",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "description": "The note on the platform's own site",
            "nullable": true
          },
          "suggestedClients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The clients the attendees matched, when more than one did; offered first when filing",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The client the note is on, when its status is Matched; null otherwise",
            "nullable": true
          },
          "taskCode": {
            "type": "string",
            "description": "The client's task the note is linked to, when its status is Matched; null otherwise",
            "nullable": true
          },
          "ignoredDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A note from a meeting note taker: Unmatched (its attendees matched no client, or several), Ignored, or Matched\n(on a client's Meetings tab)."
      },
      "ExternalMeetingNoteDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalMeetingNoteDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ExternalMeetingNoteSortField": {
        "enum": [
          "StartTime"
        ],
        "type": "string",
        "example": "StartTime"
      },
      "ExternalMeetingNoteStatus": {
        "enum": [
          "Unmatched",
          "Ignored",
          "Matched"
        ],
        "type": "string",
        "example": "Unmatched"
      },
      "ExternalProposalDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "External platform ID",
            "nullable": true
          },
          "proposalNumber": {
            "type": "string",
            "description": "Human-readable reference number (e.g., P-001234)",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "Optional title",
            "nullable": true
          },
          "status": {
            "type": "string",
            "description": "Current status on the external platform",
            "nullable": true
          },
          "price": {
            "type": "number",
            "description": "Total price",
            "format": "double"
          },
          "recurringPrice": {
            "type": "number",
            "description": "Recurring component of the price",
            "format": "double"
          },
          "oneOffPrice": {
            "type": "number",
            "description": "One-off component of the price",
            "format": "double"
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 currency code",
            "nullable": true
          },
          "plannedStart": {
            "type": "string",
            "description": "Planned start date",
            "format": "date",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "End date",
            "format": "date",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "description": "When the proposal was created",
            "format": "date-time",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "Primary client name on the external platform",
            "nullable": true
          },
          "clientId": {
            "type": "string",
            "description": "Primary client ID on the external platform",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "description": "URL to view/edit the proposal on the external platform",
            "nullable": true
          },
          "approvalLink": {
            "type": "string",
            "description": "URL for the client to approve the proposal",
            "nullable": true
          },
          "version": {
            "type": "integer",
            "description": "Version number",
            "format": "int32"
          },
          "contactName": {
            "type": "string",
            "description": "Primary contact name",
            "nullable": true
          },
          "contactEmail": {
            "type": "string",
            "description": "Primary contact email",
            "nullable": true
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalProposalLineDto"
            },
            "description": "Line items on the proposal (populated on detail only)",
            "nullable": true
          },
          "importedClient": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "hasServicesAssigned": {
            "type": "boolean",
            "description": "Whether the imported client has services from this proposal assigned.\nTrue when at least one mapped service exists on the client."
          }
        },
        "additionalProperties": false,
        "description": "A proposal from an external platform (Socket, etc.)"
      },
      "ExternalProposalDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalProposalDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ExternalProposalLineAction": {
        "enum": [
          "None",
          "Create",
          "Activate",
          "Update",
          "ActivateAndUpdate",
          "NeedsHandEdit"
        ],
        "type": "string",
        "example": "None"
      },
      "ExternalProposalLineDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "External platform line ID",
            "nullable": true
          },
          "serviceTemplateId": {
            "type": "string",
            "description": "Service template ID on the external platform (used for service mapping)",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "Line item title / service name",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Line item description",
            "nullable": true
          },
          "isRecurring": {
            "type": "boolean",
            "description": "Whether this is a recurring charge"
          },
          "price": {
            "type": "number",
            "description": "Price for this line",
            "format": "double"
          },
          "billingMethod": {
            "type": "string",
            "description": "Billing method (e.g., \"fixed\", \"hourly\")",
            "nullable": true
          },
          "mappedService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "isIgnored": {
            "type": "boolean",
            "description": "True when the practice has chosen to ignore this line's service template, so no Sodium service is created for it"
          },
          "hasOnboardingTasks": {
            "type": "boolean",
            "description": "Whether the mapped service has active onboarding task templates, so adding it to the client can create onboarding tasks"
          },
          "isAssignedToClient": {
            "type": "boolean",
            "description": "Whether this mapped service has already been assigned to the client"
          },
          "clientServiceStatus": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "plannedAction": {
            "$ref": "#/components/schemas/ExternalProposalLineAction"
          }
        },
        "additionalProperties": false,
        "description": "A line item on an external proposal"
      },
      "ExternalProposalSortField": {
        "enum": [
          "ProposalNumber",
          "Title",
          "ClientName",
          "Status",
          "Price",
          "PlannedStart"
        ],
        "type": "string",
        "example": "ProposalNumber"
      },
      "ExternalServiceMappingDto": {
        "type": "object",
        "properties": {
          "mappedService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "isIgnored": {
            "type": "boolean",
            "description": "True when no Sodium service is created for this external service"
          }
        },
        "additionalProperties": false,
        "description": "How an external service template is handled in Sodium: mapped to a BillableService, or ignored"
      },
      "FeeOverrideReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/FeeOverrideSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/FeeOverrideRowDtoPagedResult"
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Fee overrides report: every fee that differs from its default today, one row per fee, with\nwho made the override and when (docs/features/FeeOverrides/PLAN.md D4, D5). Defaults are worked\nout from today's price list. Ended services, rejected proposals and skipped schedule lines are\nleft out; billed schedule lines stay in."
      },
      "FeeOverrideRowDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name",
            "nullable": true
          },
          "feeType": {
            "$ref": "#/components/schemas/FeeOverrideType"
          },
          "clientServiceCode": {
            "type": "string",
            "description": "The client service's own code (to open it); null for package price rows, package schedule lines\nand one-off charges",
            "nullable": true
          },
          "serviceName": {
            "type": "string",
            "description": "What the fee is for: the service's name, the package's name, or a one-off charge's description",
            "nullable": true
          },
          "packageCode": {
            "type": "string",
            "description": "The package's code, for package price rows and package schedule lines",
            "nullable": true
          },
          "packageName": {
            "type": "string",
            "description": "The package's name, for package price rows and package schedule lines",
            "nullable": true
          },
          "serviceStatus": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "proposalCode": {
            "type": "string",
            "description": "The proposal the service is on while Proposed; null otherwise",
            "nullable": true
          },
          "scheduleItemCode": {
            "type": "string",
            "description": "Schedule lines and one-off charges: the line's code",
            "nullable": true
          },
          "billingDate": {
            "type": "string",
            "description": "Schedule lines and one-off charges: when the line bills or billed",
            "format": "date",
            "nullable": true
          },
          "defaultFee": {
            "type": "number",
            "description": "What the fee would be without the override, from today's price list; null for a one-off charge\n(and a catch-up fee with no months to work it out from). For a per-hour, per-day or per-unit\nservice the price is a rate per unit.",
            "format": "double",
            "nullable": true
          },
          "overriddenFee": {
            "type": "number",
            "description": "The fee as overridden",
            "format": "double"
          },
          "difference": {
            "type": "number",
            "description": "Overridden minus default (the whole amount when there is no default): negative is a discount",
            "format": "double"
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "differencePerYear": {
            "type": "number",
            "description": "The difference over a year: times periods per year for a recurring price or package price (and\ntimes the expected quantity for a per-unit rate), the difference once for one-off fees",
            "format": "double"
          },
          "byUserCode": {
            "type": "string",
            "description": "The team member who made the override; null when the system or the client made it",
            "nullable": true
          },
          "byName": {
            "type": "string",
            "description": "Who made the override: the team member's name, or \"System\" or \"Client\"",
            "nullable": true
          },
          "byType": {
            "$ref": "#/components/schemas/AuditUserType"
          },
          "when": {
            "type": "string",
            "description": "When the override was made: the most recent change that switched it on or moved the amount (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "One overridden fee on the Fee overrides report"
      },
      "FeeOverrideRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FeeOverrideRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "FeeOverrideSummaryDto": {
        "type": "object",
        "properties": {
          "totalDifferencePerYear": {
            "type": "number",
            "description": "The rows' differences per year, summed: negative when the practice charges less than its defaults",
            "format": "double"
          },
          "overrideCount": {
            "type": "integer",
            "description": "Number of rows (overridden fees)",
            "format": "int32"
          },
          "servicesWithOverrideCount": {
            "type": "integer",
            "description": "Active client services with at least one row (a schedule line counts for its service)",
            "format": "int32"
          },
          "activeServiceCount": {
            "type": "integer",
            "description": "All active client services the user can see",
            "format": "int32"
          },
          "shareOfActiveServices": {
            "type": "number",
            "description": "Services with an override as a share of all active services, as a percentage; null when there\nare no active services",
            "format": "double",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "The window the report covers (inclusive); null when no date range was asked for",
            "format": "date",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "The window end (inclusive); null when no date range was asked for",
            "format": "date",
            "nullable": true
          },
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FeeOverrideUserTotalDto"
            },
            "description": "Totals per person who made the overrides, for the group-by-user view: most overrides first",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Headline totals for the Fee overrides report"
      },
      "FeeOverrideType": {
        "enum": [
          "Price",
          "PackagePrice",
          "SetupFee",
          "CatchUpFee",
          "ScheduleLine",
          "OneOffCharge"
        ],
        "type": "string",
        "example": "Price"
      },
      "FeeOverrideUserTotalDto": {
        "type": "object",
        "properties": {
          "userCode": {
            "type": "string",
            "description": "The team member's code; null for the System and Client groups",
            "nullable": true
          },
          "userName": {
            "type": "string",
            "description": "The team member's name, or \"System\" or \"Client\"",
            "nullable": true
          },
          "userType": {
            "$ref": "#/components/schemas/AuditUserType"
          },
          "overrideCount": {
            "type": "integer",
            "description": "Number of overridden fees",
            "format": "int32"
          },
          "totalDifferencePerYear": {
            "type": "number",
            "description": "Their differences per year, summed",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "One person's overrides on the Fee overrides report"
      },
      "FieldDisplayWidth": {
        "enum": [
          "Small",
          "Medium",
          "Large",
          "Full"
        ],
        "type": "string",
        "example": "Small"
      },
      "FileContentHttpResult": {
        "type": "object",
        "properties": {
          "contentType": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "fileDownloadName": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "lastModified": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "readOnly": true
          },
          "entityTag": {
            "$ref": "#/components/schemas/EntityTagHeaderValue"
          },
          "enableRangeProcessing": {
            "type": "boolean",
            "readOnly": true
          },
          "fileLength": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "readOnly": true
          },
          "fileContents": {
            "$ref": "#/components/schemas/ByteReadOnlyMemory"
          }
        },
        "additionalProperties": false
      },
      "FilingCreditAutoTopUpDto": {
        "type": "object",
        "properties": {
          "below": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "The balance, in credits, below which a top-up is bought.",
            "format": "int32"
          },
          "blocks": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "Blocks bought each time.",
            "format": "int32"
          },
          "monthlyCapBlocks": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "The most blocks bought automatically in a calendar month; at least SodiumHQ.DTOs.FilingCredits.FilingCreditAutoTopUpDto.Blocks.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The automatic top-up: when a filing leaves fewer than SodiumHQ.DTOs.FilingCredits.FilingCreditAutoTopUpDto.Below credits, or needs more than are left, buy\nSodiumHQ.DTOs.FilingCredits.FilingCreditAutoTopUpDto.Blocks blocks, at most SodiumHQ.DTOs.FilingCredits.FilingCreditAutoTopUpDto.MonthlyCapBlocks blocks a calendar month."
      },
      "FilingCreditBalanceDto": {
        "type": "object",
        "properties": {
          "balance": {
            "type": "integer",
            "description": "Filing credits remaining across all of the practice's batches.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The practice's spendable filing credit balance."
      },
      "FilingCreditBatchSource": {
        "enum": [
          "AdminGrant",
          "Purchase",
          "AutoTopUp"
        ],
        "type": "string",
        "example": "AdminGrant"
      },
      "FilingCreditPricingDto": {
        "type": "object",
        "properties": {
          "creditsPerBlock": {
            "type": "integer",
            "description": "Credits in a block.",
            "format": "int32"
          },
          "blockPricePence": {
            "type": "integer",
            "description": "One block, in pence ex VAT.",
            "format": "int32"
          },
          "maxBlocksPerPurchase": {
            "type": "integer",
            "description": "The most blocks one purchase (or one top-up) may buy.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The price of filing credits, bought in blocks, in pence ex VAT."
      },
      "FilingCreditPurchaseDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The purchase's code.",
            "nullable": true
          },
          "blocks": {
            "type": "integer",
            "description": "Blocks bought.",
            "format": "int32"
          },
          "credits": {
            "type": "integer",
            "description": "Credits bought.",
            "format": "int32"
          },
          "amountPence": {
            "type": "integer",
            "description": "What it cost, in pence ex VAT.",
            "format": "int32"
          },
          "source": {
            "$ref": "#/components/schemas/FilingCreditBatchSource"
          },
          "purchasedByName": {
            "type": "string",
            "description": "Who bought it; for a top-up, who switched top-up on. Null when the user is gone.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When it was bought.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "A purchase of filing credits, by a user or by automatic top-up."
      },
      "FilingCreditPurchaseDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingCreditPurchaseDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "FilingCreditTopUpDto": {
        "type": "object",
        "properties": {
          "autoTopUp": {
            "$ref": "#/components/schemas/FilingCreditAutoTopUpDto"
          },
          "blocksThisMonth": {
            "type": "integer",
            "description": "Blocks automatic top-up has bought this month, which its cap counts.",
            "format": "int32"
          },
          "capReachedDate": {
            "type": "string",
            "description": "The day this month the monthly cap stopped a top-up; null when it has not.",
            "format": "date",
            "nullable": true
          },
          "enabledByUserName": {
            "type": "string",
            "description": "Who switched automatic top-up on: its top-ups are bought in their name.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A practice's automatic top-up of its filing credits and this calendar month's (UTC) use of it."
      },
      "FilingCreditsDto": {
        "type": "object",
        "properties": {
          "balance": {
            "type": "integer",
            "description": "Credits left. Submitting to HMRC spends them per the cost of the filing type.",
            "format": "int32"
          },
          "pricing": {
            "$ref": "#/components/schemas/FilingCreditPricingDto"
          },
          "topUp": {
            "$ref": "#/components/schemas/FilingCreditTopUpDto"
          },
          "hasPayableMandate": {
            "type": "boolean",
            "description": "Whether the practice has a Direct Debit that can collect (buying and switching top-up on need one); null when\nSodium's billing service could not say.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The practice's filing credits, read from Account Hub (shared-account-hub-service\ndocs/features/FilingCreditPurchases/PLAN.md D9): the balance, the price, the automatic top-up and whether the practice\ncan pay by Direct Debit."
      },
      "FilingHistoryAnnotation": {
        "type": "object",
        "properties": {
          "annotation": {
            "type": "string",
            "nullable": true
          },
          "date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "FilingHistoryAssociatedFiling": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "category": {
            "$ref": "#/components/schemas/FilingHistoryCategory"
          },
          "subcategory": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "descriptionValues": {
            "type": "object",
            "additionalProperties": { },
            "nullable": true
          },
          "actionDate": {
            "type": "string",
            "nullable": true
          },
          "formattedDescription": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "FilingHistoryCategory": {
        "enum": [
          "Accounts",
          "Address",
          "AnnualReturn",
          "Capital",
          "ChangeOfName",
          "Incorporation",
          "Liquidation",
          "Miscellaneous",
          "Mortgage",
          "Officers",
          "Resolution",
          "PersonsWithSignificantControl"
        ],
        "type": "string",
        "example": "Accounts"
      },
      "FilingHistoryDocument": {
        "type": "object",
        "properties": {
          "documentId": {
            "type": "string",
            "nullable": true
          },
          "documentType": {
            "type": "string",
            "nullable": true
          },
          "documentDescription": {
            "type": "string",
            "nullable": true
          },
          "documentDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "FilingHistoryItem": {
        "type": "object",
        "properties": {
          "transactionId": {
            "type": "string",
            "nullable": true
          },
          "date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "category": {
            "$ref": "#/components/schemas/FilingHistoryCategory"
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "subcategory": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "actionDate": {
            "type": "string",
            "nullable": true
          },
          "paperFiled": {
            "type": "string",
            "nullable": true
          },
          "barcode": {
            "type": "string",
            "nullable": true
          },
          "pages": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingHistoryDocument"
            },
            "nullable": true
          },
          "descriptionValues": {
            "type": "object",
            "additionalProperties": { },
            "nullable": true
          },
          "annotations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingHistoryAnnotation"
            },
            "nullable": true
          },
          "resolutions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingHistoryResolution"
            },
            "nullable": true
          },
          "associatedFilings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingHistoryAssociatedFiling"
            },
            "nullable": true
          },
          "formattedDescription": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "FilingHistoryItemPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingHistoryItem"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "FilingHistoryResolution": {
        "type": "object",
        "properties": {
          "category": {
            "$ref": "#/components/schemas/FilingHistoryCategory"
          },
          "subcategory": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "documentId": {
            "type": "string",
            "nullable": true
          },
          "date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "receiveDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "deltaAt": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "FindStaffByEmailRequest": {
        "required": [
          "emails"
        ],
        "type": "object",
        "properties": {
          "emails": {
            "maxItems": 50,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The addresses, at most 50"
          }
        },
        "additionalProperties": false,
        "description": "The addresses to look up among the practice's staff"
      },
      "FontSettingsDto": {
        "type": "object",
        "properties": {
          "fontFamily": {
            "$ref": "#/components/schemas/ThemeFont"
          },
          "fontSize": {
            "type": "number",
            "description": "Font size in points",
            "format": "float"
          },
          "color": {
            "type": "string",
            "description": "Text color in hex format (e.g., \"#000000\" for black)",
            "nullable": true
          },
          "bold": {
            "type": "boolean",
            "description": "Whether the text should be bold"
          },
          "italic": {
            "type": "boolean",
            "description": "Whether the text should be italic"
          },
          "underline": {
            "type": "boolean",
            "description": "Whether the text should be underlined"
          },
          "customFontFamily": {
            "maxLength": 200,
            "type": "string",
            "description": "Custom font family name (e.g., \"Garamond\"). Only used when FontFamily is set to Custom.",
            "nullable": true
          },
          "backgroundColor": {
            "type": "string",
            "description": "Optional background color in hex format (e.g., \"#f3f4f6\"). Used for table headers.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Typography settings for a specific text element (headings, body, tables, etc.) in a design theme.\nDefines font family, size, color, and text decorations."
      },
      "ForeignDividendItem": {
        "type": "object",
        "properties": {
          "countryCode": {
            "type": "string",
            "nullable": true
          },
          "amountBeforeTax": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxTakenOff": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "specialWithholdingTax": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "foreignTaxCreditRelief": {
            "type": "boolean",
            "nullable": true
          },
          "taxableAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignIncomeTaxCreditRelief": {
        "type": "object",
        "properties": {
          "countryCode": {
            "type": "string",
            "nullable": true
          },
          "foreignTaxPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxableAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "employmentLumpSum": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignInterestItem": {
        "type": "object",
        "properties": {
          "countryCode": {
            "type": "string",
            "nullable": true
          },
          "amountBeforeTax": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxTakenOff": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "specialWithholdingTax": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "foreignTaxCreditRelief": {
            "type": "boolean",
            "nullable": true
          },
          "taxableAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyAnnualAdjustments": {
        "type": "object",
        "properties": {
          "privateUseAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "balancingCharge": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyAnnualAllowances": {
        "type": "object",
        "properties": {
          "annualInvestmentAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "costOfReplacingDomesticItems": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherCapitalAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "zeroEmissionsCarAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "propertyIncomeAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "structuredBuildingAllowance": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StructuredBuildingAllowanceItem"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyAnnualEntry": {
        "type": "object",
        "properties": {
          "countryCode": {
            "type": "string",
            "nullable": true
          },
          "propertyId": {
            "type": "string",
            "nullable": true
          },
          "adjustments": {
            "$ref": "#/components/schemas/ForeignPropertyAnnualAdjustments"
          },
          "allowances": {
            "$ref": "#/components/schemas/ForeignPropertyAnnualAllowances"
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyAnnualSubmission": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "foreignProperty": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignPropertyAnnualEntry"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsas": {
        "type": "object",
        "properties": {
          "metadata": {
            "$ref": "#/components/schemas/BsasMetadata"
          },
          "inputs": {
            "$ref": "#/components/schemas/BsasInputs"
          },
          "adjustableSummaryCalculation": {
            "$ref": "#/components/schemas/ForeignPropertyBsasCalculation"
          },
          "adjustments": {
            "$ref": "#/components/schemas/ForeignPropertyBsasAdjustments"
          },
          "adjustedSummaryCalculation": {
            "$ref": "#/components/schemas/ForeignPropertyBsasCalculation"
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsasAdditions": {
        "type": "object",
        "properties": {
          "privateUseAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "balancingCharge": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsasAdjustmentEntry": {
        "type": "object",
        "properties": {
          "countryCode": {
            "type": "string",
            "nullable": true
          },
          "propertyId": {
            "type": "string",
            "nullable": true
          },
          "income": {
            "$ref": "#/components/schemas/ForeignPropertyBsasIncome"
          },
          "expenses": {
            "$ref": "#/components/schemas/ForeignPropertyBsasExpenses"
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsasAdjustments": {
        "type": "object",
        "properties": {
          "zeroAdjustments": {
            "type": "boolean",
            "nullable": true
          },
          "detail": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignPropertyBsasAdjustmentEntry"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsasCalculation": {
        "type": "object",
        "properties": {
          "totalIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "income": {
            "$ref": "#/components/schemas/ForeignPropertyBsasIncome"
          },
          "totalExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "expenses": {
            "$ref": "#/components/schemas/ForeignPropertyBsasExpenses"
          },
          "netProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "netLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalAdditions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "additions": {
            "$ref": "#/components/schemas/ForeignPropertyBsasAdditions"
          },
          "totalDeductions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "deductions": {
            "$ref": "#/components/schemas/ForeignPropertyBsasDeductions"
          },
          "taxableProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adjustedIncomeTaxLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "countryLevelDetail": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignPropertyBsasCountryDetail"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsasCountryDetail": {
        "type": "object",
        "properties": {
          "totalIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "income": {
            "$ref": "#/components/schemas/ForeignPropertyBsasIncome"
          },
          "totalExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "expenses": {
            "$ref": "#/components/schemas/ForeignPropertyBsasExpenses"
          },
          "netProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "netLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalAdditions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "additions": {
            "$ref": "#/components/schemas/ForeignPropertyBsasAdditions"
          },
          "totalDeductions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "deductions": {
            "$ref": "#/components/schemas/ForeignPropertyBsasDeductions"
          },
          "taxableProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adjustedIncomeTaxLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "countryCode": {
            "type": "string",
            "nullable": true
          },
          "propertyLevelDetail": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignPropertyBsasPropertyDetail"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsasDeductions": {
        "type": "object",
        "properties": {
          "annualInvestmentAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "costOfReplacingDomesticItems": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "zeroEmissionGoods": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "zeroEmissionsCarAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "propertyAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherCapitalAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "structuredBuildingAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsasExpenses": {
        "type": "object",
        "properties": {
          "premisesRunningCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "repairsAndMaintenance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "financialCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "professionalFees": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "costOfServices": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "travelCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "residentialFinancialCost": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "broughtFwdResidentialFinancialCost": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "other": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "consolidatedExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsasIncome": {
        "type": "object",
        "properties": {
          "totalRentsReceived": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "premiumsOfLeaseGrant": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherPropertyIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyBsasPropertyDetail": {
        "type": "object",
        "properties": {
          "totalIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "income": {
            "$ref": "#/components/schemas/ForeignPropertyBsasIncome"
          },
          "totalExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "expenses": {
            "$ref": "#/components/schemas/ForeignPropertyBsasExpenses"
          },
          "netProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "netLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalAdditions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "additions": {
            "$ref": "#/components/schemas/ForeignPropertyBsasAdditions"
          },
          "totalDeductions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "deductions": {
            "$ref": "#/components/schemas/ForeignPropertyBsasDeductions"
          },
          "taxableProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adjustedIncomeTaxLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "propertyId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyCumulativeSummary": {
        "type": "object",
        "properties": {
          "fromDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "toDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "foreignProperty": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignPropertyPeriodEntry"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyEndReason": {
        "enum": [
          "Unknown",
          "NoLongerRentingPropertyOut",
          "Disposal",
          "AddedInError",
          "Cessation"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "ForeignPropertyExpenses": {
        "type": "object",
        "properties": {
          "premisesRunningCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "repairsAndMaintenance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "financialCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "professionalFees": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "costOfServices": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "travelCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "residentialFinancialCost": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "broughtFwdResidentialFinancialCost": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "other": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "consolidatedExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyFigureInputs": {
        "type": "object",
        "properties": {
          "foreignProperty": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignPropertyPeriodEntry"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyIncome": {
        "type": "object",
        "properties": {
          "rentIncome": {
            "$ref": "#/components/schemas/ForeignPropertyRentIncome"
          },
          "foreignTaxCreditRelief": {
            "type": "boolean",
            "nullable": true
          },
          "premiumsOfLeaseGrant": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherPropertyIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "foreignTaxPaidOrDeducted": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "specialWithholdingTaxOrUkTaxPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyPeriodEntry": {
        "type": "object",
        "properties": {
          "countryCode": {
            "type": "string",
            "nullable": true
          },
          "propertyId": {
            "type": "string",
            "nullable": true
          },
          "income": {
            "$ref": "#/components/schemas/ForeignPropertyIncome"
          },
          "expenses": {
            "$ref": "#/components/schemas/ForeignPropertyExpenses"
          }
        },
        "additionalProperties": false
      },
      "ForeignPropertyRentIncome": {
        "type": "object",
        "properties": {
          "rentAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ForeignReliefs": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "foreignTaxCreditRelief": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "foreignIncomeTaxCreditRelief": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignIncomeTaxCreditRelief"
            },
            "nullable": true
          },
          "foreignTaxForFtcrNotClaimed": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "FormQuestionTokens": {
        "type": "object",
        "properties": {
          "prompt": {
            "type": "string",
            "description": "The question, as the client saw it",
            "nullable": true
          },
          "answer": {
            "type": "string",
            "description": "The answer as HTML; blank when the client left it empty",
            "nullable": true
          },
          "tokenName": {
            "type": "string",
            "description": "The question's token name: its answer is also {{ Form.Answers.<TokenName> }}",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One answered question."
      },
      "FormSectionTokens": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "The section's title, as the client saw it",
            "nullable": true
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormQuestionTokens"
            },
            "description": "The section's answered questions, in form order",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A form section that has answers."
      },
      "FormTokens": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The form's name",
            "nullable": true
          },
          "submittedAt": {
            "type": "string",
            "description": "When the client submitted it, UK time. Usage: {{ Form.SubmittedAt | formatDate: \"dd MMM yyyy\" }}",
            "format": "date-time",
            "nullable": true
          },
          "submittedByName": {
            "type": "string",
            "description": "The name of the client contact who submitted it, else their email address; blank when unknown",
            "nullable": true
          },
          "submittedByEmail": {
            "type": "string",
            "description": "The email address the form was submitted from; blank when unknown",
            "nullable": true
          },
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormSectionTokens"
            },
            "description": "The sections that have answers, in form order, each with its answered questions",
            "nullable": true
          },
          "answers": {
            "type": "object",
            "additionalProperties": { },
            "description": "Each answered question's answer by its token name; blank for an empty answer. A name the form no longer has\nrenders blank. Usage: {{ Form.Answers.annual_turnover }}",
            "nullable": true
          },
          "allAnswers": {
            "type": "string",
            "description": "Every section's title and a table of its questions and answers, as the Basic layout shows them; an empty\nanswer reads \"No answer\". Usage: {{ Form.AllAnswers }}",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A submitted form's answers, for exporting them as a document. Set only for that export; null in every other render.\nEvery text value is HTML already: the client's answers are encoded (rich text answers are kept, already sanitised),\nso templates output them as they are.\nUsage in templates: {{ Form.Name }}, {% for section in Form.Sections %}...{% endfor %}"
      },
      "ForwardMailboxEmailRequest": {
        "required": [
          "htmlBody",
          "toRecipients"
        ],
        "type": "object",
        "properties": {
          "toRecipients": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "To recipients. At least one is required: a forward has no default recipient."
          },
          "ccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "CC recipients. Null or empty = none.",
            "nullable": true
          },
          "bccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "BCC recipients. Null or empty = none.",
            "nullable": true
          },
          "subject": {
            "type": "string",
            "description": "Subject line. Null or blank = \"Fwd: \" followed by the original's subject.",
            "nullable": true
          },
          "keepAttachmentIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ids of the original's attachments to carry, as the message detail endpoint returns them.\nNull = every non-inline attachment of the original. Empty = none. Inline images the original's\nbody shows are always carried, so the forwarded body renders.",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAttachmentDto"
            },
            "description": "New attachments to add, as base64 content. Null or empty = none.",
            "nullable": true
          },
          "htmlBody": {
            "minLength": 1,
            "type": "string",
            "description": "HTML the user wrote above the forwarded message (signature included). Redeclared from the email\nservice contract so it is cleaned as the request is read."
          },
          "practiceDocumentCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of practice documents (tenant document library) to attach. Resolved to file\ncontent server-side, so the browser never round-trips the document bytes.",
            "nullable": true
          },
          "scheduledAt": {
            "type": "string",
            "description": "When set, the forward is not sent now: a scheduled send is created and dispatched at this\nUTC instant. Must be in the future. Omit to send immediately.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to forward a mailbox message to new recipients, extending the email service forward\ncontract with practice document attachments resolved server-side by code. At least one To\nrecipient is required."
      },
      "GenerateBillableServiceRequest": {
        "required": [
          "serviceName"
        ],
        "type": "object",
        "properties": {
          "serviceName": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the service to generate"
          }
        },
        "additionalProperties": false,
        "description": "Request to generate a BillableService using AI"
      },
      "GenerateWorkflowRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the workflow to generate"
          },
          "description": {
            "type": "string",
            "description": "Optional description providing context for the workflow generation",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to generate a Workflow using AI"
      },
      "GetMessageResponse": {
        "type": "object",
        "properties": {
          "messageId": {
            "type": "string",
            "description": "Unique message ID",
            "format": "uuid"
          },
          "status": {
            "$ref": "#/components/schemas/EmailStatus"
          },
          "createdDate": {
            "type": "string",
            "description": "When the message was created",
            "format": "date-time"
          },
          "processedAt": {
            "type": "string",
            "description": "When the message was processed",
            "format": "date-time",
            "nullable": true
          },
          "sentAt": {
            "type": "string",
            "description": "When the message was sent",
            "format": "date-time",
            "nullable": true
          },
          "retryCount": {
            "type": "integer",
            "description": "Number of retry attempts",
            "format": "int32"
          },
          "nextRetryAt": {
            "type": "string",
            "description": "When the next send attempt is due (retry or rate-limit deferral); null when none is scheduled",
            "format": "date-time",
            "nullable": true
          },
          "lastError": {
            "type": "string",
            "description": "Last error message if any",
            "nullable": true
          },
          "externalReference": {
            "type": "string",
            "description": "External reference from calling application",
            "nullable": true
          },
          "configCode": {
            "type": "string",
            "description": "Configuration code (GUID) of the mailbox the message is sent from, the ConfigCode the mailbox\nendpoints use for it",
            "nullable": true
          },
          "providerMessageId": {
            "type": "string",
            "description": "The sent email's id at the provider (Graph immutable id, Gmail id, SMTP Message-ID); null\nuntil sent",
            "nullable": true
          },
          "providerThreadId": {
            "type": "string",
            "description": "The sent email's thread at the provider (Graph conversationId, Gmail threadId), the ConversationId\nits synced copy has in the mailbox endpoints. Null until sent, and always null for SMTP, SendGrid\nand send-only Microsoft 365 mailboxes, whose sends report no thread.",
            "nullable": true
          },
          "subject": {
            "type": "string",
            "description": "Email subject line",
            "nullable": true
          },
          "fromEmail": {
            "type": "string",
            "description": "Sender email address",
            "nullable": true
          },
          "fromName": {
            "type": "string",
            "description": "Sender display name",
            "nullable": true
          },
          "replyToEmail": {
            "type": "string",
            "description": "Reply-to email address",
            "nullable": true
          },
          "replyToName": {
            "type": "string",
            "description": "Reply-to display name",
            "nullable": true
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "List of To recipients",
            "nullable": true
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "List of Cc recipients",
            "nullable": true
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "List of Bcc recipients",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAttachmentInfoDto"
            },
            "description": "List of attachments (metadata only, not content)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response for get message request containing full message details"
      },
      "GiftAidPayments": {
        "type": "object",
        "properties": {
          "nonUkCharities": {
            "$ref": "#/components/schemas/NonUkCharities"
          },
          "totalAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "oneOffAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountTreatedAsPreviousTaxYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountTreatedAsSpecifiedTaxYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GrantScope": {
        "enum": [
          "UserAccount",
          "SingleOrganisation"
        ],
        "type": "string",
        "example": "UserAccount"
      },
      "HmrcAccountingType": {
        "enum": [
          "Cash",
          "Accrual"
        ],
        "type": "string",
        "example": "Cash"
      },
      "HmrcAgentCredentialDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "What the practice calls this set.",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "The set MTD uses for the ARN, and that letter-based requests use when no set is chosen."
          },
          "agentReferenceNumber": {
            "type": "string",
            "description": "Agent Reference Number (ARN) from the Agent Services Account. Used for MTD digital authorisations.",
            "nullable": true
          },
          "saAgentCode": {
            "type": "string",
            "description": "Self Assessment agent code (e.g. A12345).",
            "nullable": true
          },
          "payeAgentCode": {
            "type": "string",
            "description": "PAYE/CIS agent code (e.g. 123/A12345).",
            "nullable": true
          },
          "ctAgentCode": {
            "type": "string",
            "description": "Corporation Tax agent code.",
            "nullable": true
          },
          "contactFirstName": {
            "type": "string",
            "description": "First name of the agent contact. Included in HMRC XML submissions.",
            "nullable": true
          },
          "contactLastName": {
            "type": "string",
            "description": "Last name of the agent contact. Included in HMRC XML submissions.",
            "nullable": true
          },
          "contactEmail": {
            "type": "string",
            "description": "Email of the agent contact. Included in HMRC XML submissions.",
            "nullable": true
          },
          "govGatewayUserId": {
            "type": "string",
            "description": "Government Gateway user ID for HMRC XML API submissions.",
            "nullable": true
          },
          "govGatewayPasswordSet": {
            "type": "boolean",
            "description": "Whether a Government Gateway password is stored."
          },
          "useTestGateway": {
            "type": "boolean",
            "description": "CIS Manager files this set's returns with HMRC's test gateway, not the live one."
          },
          "testInLive": {
            "type": "boolean",
            "description": "CIS Manager flags this set's live returns as tests. Always false with the test gateway."
          }
        },
        "additionalProperties": false,
        "description": "One set of HMRC agent details: a Government Gateway login with the ARN, agent codes and agent\ncontact that go with it. The password is never returned."
      },
      "HmrcAgentCredentialDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HmrcAgentCredentialDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "HmrcAgentCredentialOptionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "What the practice calls this set.",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether this is the default set, which the dialog preselects."
          }
        },
        "additionalProperties": false,
        "description": "A credential set as the request dialog lists it: enough to choose one, nothing more."
      },
      "HmrcAgentCredentialSortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "HmrcAgentRole": {
        "enum": [
          "None",
          "Main",
          "Supporting",
          "NotApplicable"
        ],
        "type": "string",
        "example": "None"
      },
      "HmrcBatchRequestError": {
        "type": "object",
        "properties": {
          "authorisationType": {
            "type": "string",
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "HmrcBatchRequestResult": {
        "type": "object",
        "properties": {
          "succeeded": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "failed": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HmrcBatchRequestError"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "HmrcBulkRequestClientCheckDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code.",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name.",
            "nullable": true
          },
          "issues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HmrcBulkRequestIssueDto"
            },
            "description": "Details to fill in or correct before this client can be sent. Never null.",
            "nullable": true
          },
          "problem": {
            "type": "string",
            "description": "Why this client cannot be sent from the bulk request at all (already requested, no main contact to hold a\nSelf Assessment UTR). Null when only details are missing.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One client checked for a bulk 64-8 request, and anything stopping it"
      },
      "HmrcBulkRequestClientDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code.",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/HmrcBulkRequestClientStatus"
          },
          "error": {
            "type": "string",
            "description": "Why it failed (null unless Failed).",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One client of a bulk 64-8 request and how its send went"
      },
      "HmrcBulkRequestClientInputDto": {
        "required": [
          "clientCode"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The client's code."
          },
          "utr": {
            "maxLength": 50,
            "type": "string",
            "description": "A UTR to save to the client before sending.",
            "nullable": true
          },
          "postcode": {
            "maxLength": 10,
            "type": "string",
            "description": "A postcode for this request only.",
            "nullable": true
          },
          "payeRef": {
            "maxLength": 50,
            "type": "string",
            "description": "A PAYE reference to save to the client before sending.",
            "nullable": true
          },
          "accountsOfficeRef": {
            "maxLength": 50,
            "type": "string",
            "description": "An Accounts Office reference to save to the client before sending.",
            "nullable": true
          },
          "email": {
            "maxLength": 320,
            "type": "string",
            "description": "Who gets the code entry link, for this request only.",
            "format": "email",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One client to send in a bulk request. The details are only those the practice filled in: the UTR and the PAYE and\nAccounts Office references are saved to the client, the postcode and email go with this request only. Anything left\nout is read from the client's record."
      },
      "HmrcBulkRequestClientStatus": {
        "enum": [
          "Queued",
          "Sent",
          "Failed"
        ],
        "type": "string",
        "example": "Queued"
      },
      "HmrcBulkRequestDto": {
        "type": "object",
        "properties": {
          "queuedCount": {
            "type": "integer",
            "description": "How many clients are still waiting their turn.",
            "format": "int32"
          },
          "sentCount": {
            "type": "integer",
            "description": "How many requests HMRC accepted.",
            "format": "int32"
          },
          "failedCount": {
            "type": "integer",
            "description": "How many requests failed.",
            "format": "int32"
          },
          "isComplete": {
            "type": "boolean",
            "description": "Whether every client has been sent or has failed."
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HmrcBulkRequestClientDto"
            },
            "description": "Every client in the bulk request, by name.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A bulk 64-8 request's progress: each client, and whether its request reached HMRC"
      },
      "HmrcBulkRequestField": {
        "enum": [
          "Utr",
          "Postcode",
          "PayeRef",
          "AccountsOfficeRef",
          "Email"
        ],
        "type": "string",
        "description": "A detail a 64-8 request needs that a client in a bulk request is missing or holds in the wrong form",
        "example": "Utr"
      },
      "HmrcBulkRequestIssueDto": {
        "type": "object",
        "properties": {
          "field": {
            "$ref": "#/components/schemas/HmrcBulkRequestField"
          },
          "message": {
            "type": "string",
            "description": "What is wrong with it, in words for the practice.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One detail a client is missing, or holds in a form HMRC would reject"
      },
      "HmrcBulkRequestNotSentDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code.",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name, when the client exists.",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "description": "Why it was left out.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client left out of a bulk request when it was started, and why"
      },
      "HmrcBulkRequestStartedDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The bulk request's code, to read its progress with. Null when no client could be sent.",
            "nullable": true
          },
          "notSent": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HmrcBulkRequestNotSentDto"
            },
            "description": "The clients left out, and why. Never null.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A bulk request just started: the clients queued to go to HMRC, and those left out"
      },
      "HmrcClientListApplyResultDto": {
        "type": "object",
        "properties": {
          "updatedCount": {
            "type": "integer",
            "description": "How many clients' status changed; clients already at the confirmed status are not counted.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "What applying an HMRC client list changed."
      },
      "HmrcClientListChangeDto": {
        "required": [
          "clientCode",
          "status"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "maxLength": 50,
            "minLength": 1,
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/AgentAuthorisationStatus"
          }
        },
        "additionalProperties": false,
        "description": "One client's new status."
      },
      "HmrcClientListMatchBasis": {
        "enum": [
          "None",
          "TaxReference",
          "CompanyNumber",
          "ClientReference",
          "Name"
        ],
        "type": "string",
        "example": "None"
      },
      "HmrcClientListPreviewDto": {
        "type": "object",
        "properties": {
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HmrcClientListRowDto"
            },
            "description": "Every client on the list, in the file's order.",
            "nullable": true
          },
          "notOnList": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Clients recorded as Granted for this type that are not on the list.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What uploading an HMRC client list would change, for the practice to check before anything is\nsaved: each row with the client it was matched to, and the clients recorded as authorised that\nthe list does not show."
      },
      "HmrcClientListRowDto": {
        "type": "object",
        "properties": {
          "line": {
            "type": "integer",
            "description": "The row's line in the file, counting the header as line 1.",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "description": "The name as HMRC hold it.",
            "nullable": true
          },
          "taxReference": {
            "type": "string",
            "description": "The UTR or employer PAYE reference on the list.",
            "nullable": true
          },
          "agentReference": {
            "type": "string",
            "description": "The reference the practice gave the client at HMRC, if any.",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "matchBasis": {
            "$ref": "#/components/schemas/HmrcClientListMatchBasis"
          },
          "possibleMatchCount": {
            "type": "integer",
            "description": "How many clients the row could have been, when more than one (and so it matched none).",
            "format": "int32"
          },
          "currentStatus": {
            "$ref": "#/components/schemas/AgentAuthorisationStatus"
          },
          "isAwaitingCode": {
            "type": "boolean",
            "description": "True when the matched client has a letter request awaiting its posted code, which the list shows is now granted."
          }
        },
        "additionalProperties": false,
        "description": "One client on an HMRC client list and the client it was matched to."
      },
      "HmrcConnectResponseDto": {
        "type": "object",
        "properties": {
          "authorizationUrl": {
            "type": "string",
            "description": "The HMRC authorization URL to send the user to for the consent journey.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response to starting the HMRC consent journey."
      },
      "HmrcConnectionStatusDto": {
        "type": "object",
        "properties": {
          "isConnected": {
            "type": "boolean",
            "description": "Whether the practice has an active HMRC connection."
          },
          "status": {
            "type": "string",
            "description": "The connection's lifecycle status (Active, Expired, ...), when one exists.",
            "nullable": true
          },
          "isSandbox": {
            "type": "boolean",
            "description": "Whether the connection targets the HMRC sandbox environment.",
            "nullable": true
          },
          "connectedDate": {
            "type": "string",
            "description": "When the connection was created.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The practice's HMRC connection status."
      },
      "HmrcFinalDeclarationType": {
        "enum": [
          "Unknown",
          "FinalDeclaration",
          "ConfirmAmendment"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "HmrcInvitationDetailsDto": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/HmrcInvitationStatus"
          },
          "clientActionUrl": {
            "type": "string",
            "description": "The URL the client clicks to approve the authorisation on Government Gateway.",
            "nullable": true
          },
          "dateRequested": {
            "type": "string",
            "description": "When the HMRC invitation was created.",
            "format": "date-time",
            "nullable": true
          },
          "expiresOn": {
            "type": "string",
            "description": "When the HMRC invitation expires.",
            "format": "date-time",
            "nullable": true
          },
          "codeEntryEmailSentDate": {
            "type": "string",
            "description": "When the client was emailed the link for entering the code HMRC posted to them (letter-based\nrequests only). Null when they have not been invited to enter it themselves.",
            "format": "date-time",
            "nullable": true
          },
          "hmrcCredentialName": {
            "type": "string",
            "description": "The name of the HMRC credential set whose Government Gateway login made this letter-based\nrequest. Null for digital requests, and for letter requests made before credential sets\nexisted (they use the default set).",
            "nullable": true
          },
          "requestedByName": {
            "type": "string",
            "description": "The name of the person who made the request. Null for requests made before this was recorded.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Details of an HMRC digital authorisation invitation"
      },
      "HmrcInvitationStatus": {
        "enum": [
          "Pending",
          "Accepted",
          "Rejected",
          "Expired",
          "Cancelled",
          "Deauthorised",
          "PartialAuth",
          "LetterRequested"
        ],
        "type": "string",
        "example": "Pending"
      },
      "HmrcItsaStatus": {
        "enum": [
          "NoStatus",
          "MtdMandated",
          "MtdVoluntary",
          "Annual",
          "DigitallyExempt",
          "Dormant",
          "MtdExempt"
        ],
        "type": "string",
        "example": "NoStatus"
      },
      "HmrcLossClaimType": {
        "enum": [
          "Unknown",
          "CarryForward",
          "CarrySideways",
          "CarrySidewaysFhl",
          "CarryForwardToCarrySideways"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "HmrcLossPreferenceOrder": {
        "enum": [
          "Unknown",
          "CarrySideways",
          "CarryBack"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "HmrcLossType": {
        "enum": [
          "Unknown",
          "SelfEmployment",
          "SelfEmploymentClass4",
          "UkPropertyFhl",
          "UkProperty",
          "ForeignPropertyFhlEea",
          "ForeignProperty"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "HmrcObligationStatus": {
        "enum": [
          "Open",
          "Fulfilled"
        ],
        "type": "string",
        "example": "Open"
      },
      "HmrcQuarterlyPeriodType": {
        "enum": [
          "Unknown",
          "Standard",
          "Calendar"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "HmrcSubmissionAction": {
        "enum": [
          "Unknown",
          "Submitted",
          "Deleted"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "HmrcSubmissionKind": {
        "enum": [
          "Unknown",
          "SelfEmploymentAnnual",
          "UkPropertyAnnual",
          "BsasSelfEmploymentAdjustment",
          "BsasUkPropertyAdjustment",
          "DividendsIncome",
          "UkDividendsIncome",
          "DirectorshipDividend",
          "SavingsAccountInterest",
          "OtherSavingsIncome",
          "InvestmentReliefs",
          "OtherReliefs",
          "ForeignReliefs",
          "PensionsReliefs",
          "CharitableGivingReliefs",
          "OtherCapitalGains",
          "CgtResidentialDisposals",
          "CustomEmployment",
          "EmploymentFinancialDetails",
          "NonPayeEmploymentIncome",
          "OtherEmploymentIncome",
          "AccountingType",
          "PeriodsOfAccount",
          "LateAccountingDateRuleElection",
          "BroughtForwardLoss",
          "LossClaim",
          "LossClaimsOrder",
          "LossesAndClaims",
          "ForeignPropertyAnnual",
          "ForeignPropertyRegistration",
          "BsasForeignPropertyAdjustment",
          "TaxLiabilityAdjustments",
          "TaxReturn",
          "CgtPpdOverrides",
          "StudentLoanBenefitInKind"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "HmrcVerificationResult": {
        "enum": [
          "NotChecked",
          "Confirmed",
          "NotFound",
          "MissingDetails",
          "Failed"
        ],
        "type": "string",
        "example": "NotChecked"
      },
      "HolidayAdjustment": {
        "enum": [
          "None",
          "Skip",
          "MoveBefore",
          "MoveAfter"
        ],
        "type": "string",
        "example": "None"
      },
      "HttpValidationProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "IResult": {
        "type": "object",
        "additionalProperties": false
      },
      "ImageAssetDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier (GUID)",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Name of the image asset",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Description of the image asset",
            "nullable": true
          },
          "originalFileName": {
            "type": "string",
            "description": "Original file name",
            "nullable": true
          },
          "contentType": {
            "type": "string",
            "description": "MIME type of the image",
            "nullable": true
          },
          "fileSize": {
            "type": "integer",
            "description": "File size in bytes",
            "format": "int64"
          },
          "widthPx": {
            "type": "integer",
            "description": "Image width in pixels (null for SVG)",
            "format": "int32",
            "nullable": true
          },
          "heightPx": {
            "type": "integer",
            "description": "Image height in pixels (null for SVG)",
            "format": "int32",
            "nullable": true
          },
          "sha256Hash": {
            "type": "string",
            "description": "SHA256 hash of the file",
            "nullable": true
          },
          "downloadUrl": {
            "type": "string",
            "description": "SAS URL for downloading the image (generated on-demand)",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "Date when the asset was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "Date when the asset was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Data transfer object for image asset details"
      },
      "ImageAssetDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImageAssetDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ImageAssetSortField": {
        "enum": [
          "Name",
          "FileSize"
        ],
        "type": "string",
        "example": "Name"
      },
      "ImportBillableServicesFromLibraryRequest": {
        "required": [
          "libraryCodes"
        ],
        "type": "object",
        "properties": {
          "libraryCodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LibraryServiceImportItem"
            },
            "description": "The library services to import, each with a library code and optional overrides"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for importing one or more billable services from the library"
      },
      "ImportFromLibraryRequest": {
        "type": "object",
        "properties": {
          "nameSuffix": {
            "type": "string",
            "description": "Suffix appended to the imported entity's Name on re-import (e.g. \"v2\", \"May 2026\").\nNull / empty means: server picks the next \"(N)\" if a row for this LibraryCode already\nexists in the tenant; no suffix on a first import.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request body for single-item library imports (Workflow, DocumentTemplate, DataForm).\nOptional — empty body / null fields are still accepted for first-time imports."
      },
      "ImportJobClientDto": {
        "type": "object",
        "properties": {
          "externalId": {
            "type": "string",
            "description": "The client ID from the external system (e.g., Xero contact ID)",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The client's name on the external platform. Null when the platform never returned the\nclient - fall back to the external ID for display.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ImportJobClientStatus"
          },
          "errorMessage": {
            "type": "string",
            "description": "Why this client failed to import. Null for any status other than Failed.",
            "nullable": true
          },
          "processedDate": {
            "type": "string",
            "description": "When this client was processed",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of a single client within an import job, including why it failed"
      },
      "ImportJobClientDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportJobClientDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ImportJobClientStatus": {
        "enum": [
          "Pending",
          "InProgress",
          "Completed",
          "Failed",
          "Skipped"
        ],
        "type": "string",
        "example": "Pending"
      },
      "ImportJobDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for this import job",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ImportJobStatus"
          },
          "totalItems": {
            "type": "integer",
            "description": "Total number of items to be imported",
            "format": "int32",
            "nullable": true
          },
          "processedItems": {
            "type": "integer",
            "description": "Number of items processed so far",
            "format": "int32"
          },
          "successCount": {
            "type": "integer",
            "description": "Number of items successfully imported",
            "format": "int32"
          },
          "failureCount": {
            "type": "integer",
            "description": "Number of items that failed to import",
            "format": "int32"
          },
          "skippedCount": {
            "type": "integer",
            "description": "Number of items skipped because the platform client was already imported",
            "format": "int32"
          },
          "leftForReviewCount": {
            "type": "integer",
            "description": "Number of clients an Import All left out because each matches a client already in Sodium. They stay on\nthe import page, where they can be linked or imported as new.",
            "format": "int32"
          },
          "errorMessage": {
            "type": "string",
            "description": "Why the job as a whole failed. Set only when Status is Failed, and only for job-level\nfailures (deleted connection, unsupported platform, unhandled error) - per-client failure\nreasons come from the import job clients endpoint instead.",
            "nullable": true
          },
          "enrichFromCompaniesHouse": {
            "type": "boolean",
            "description": "Whether Companies House enrichment is enabled"
          },
          "defaultClientType": {
            "$ref": "#/components/schemas/ClientType"
          },
          "startedDate": {
            "type": "string",
            "description": "When the job started processing",
            "format": "date-time",
            "nullable": true
          },
          "completedDate": {
            "type": "string",
            "description": "When the job completed",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the job was created",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "DTO representing an import job status"
      },
      "ImportJobStatus": {
        "enum": [
          "Queued",
          "InProgress",
          "Completed",
          "Failed",
          "Cancelled",
          "Draft"
        ],
        "type": "string",
        "example": "Queued"
      },
      "ImportPipelinesFromLibraryRequest": {
        "required": [
          "libraryCodes"
        ],
        "type": "object",
        "properties": {
          "libraryCodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LibraryPipelineImportItem"
            },
            "description": "The library pipelines to import, each with a library code and optional overrides"
          }
        },
        "additionalProperties": false,
        "description": "Request to import one or more pipelines from the library"
      },
      "ImportTaskTemplatesFromLibraryRequest": {
        "required": [
          "libraryCodes"
        ],
        "type": "object",
        "properties": {
          "libraryCodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LibraryTaskTemplateImportItem"
            },
            "description": "The library task templates to import"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for importing one or more one-off task templates from the library"
      },
      "ImportWorkflowsFromLibraryRequest": {
        "required": [
          "libraryCodes"
        ],
        "type": "object",
        "properties": {
          "libraryCodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LibraryWorkflowImportItem"
            },
            "description": "The library workflows to import, each with a library code and optional name suffix."
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for importing one or more workflows from the library in a single call."
      },
      "InitializeWorkflowStepsRequest": {
        "required": [
          "workflowCode"
        ],
        "type": "object",
        "properties": {
          "workflowCode": {
            "maxLength": 50,
            "minLength": 1,
            "type": "string",
            "description": "The workflow code to initialize steps for.\nMust be a valid workflow code that exists in the tenant.\n            \nWarning: This operation will:\n- Clear all existing workflow step progress for the task\n- Create new step instances based on the workflow template\n- Reset all progress counters to zero\n- Set initial assignments based on workflow step rules"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for initializing or re-initializing workflow steps for a TaskItem.\nUsed when a workflow is first assigned to a task or when changing workflows.\n            \nAPI Usage:\n- POST /api/tenants/{tenant}/tasks/{taskCode}/workflow\n- Typically called automatically when a workflow is assigned to a task\n- Can be called manually to reset workflow progress\n            \nExample Usage:\n```\nPOST /api/tenants/acme/tasks/TASK-001/workflow\n{\n    \"workflowCode\": \"CLIENT-ONBOARDING\"\n}\n```"
      },
      "InitiateMandateSetupRequest": {
        "required": [
          "successRedirectUrl"
        ],
        "type": "object",
        "properties": {
          "successRedirectUrl": {
            "minLength": 1,
            "type": "string",
            "description": "The URL to redirect the user to after completing the mandate setup on GoCardless."
          }
        },
        "additionalProperties": false,
        "description": "Request model for initiating a GoCardless Direct Debit mandate setup."
      },
      "InvestmentReliefs": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "vctSubscription": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "nullable": true
          },
          "eisSubscription": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "nullable": true
          },
          "communityInvestment": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "nullable": true
          },
          "seedEnterpriseInvestment": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "nullable": true
          },
          "socialEnterpriseInvestment": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "InvestmentSubscription": {
        "type": "object",
        "properties": {
          "uniqueInvestmentRef": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "knowledgeIntensive": {
            "type": "boolean",
            "nullable": true
          },
          "dateOfInvestment": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "amountInvested": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "reliefClaimed": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "InvitationDetailsResponse": {
        "type": "object",
        "properties": {
          "tenantName": {
            "type": "string",
            "description": "The name of the tenant/practice",
            "nullable": true
          },
          "tenantCode": {
            "type": "string",
            "description": "The code of the tenant",
            "nullable": true
          },
          "userEmail": {
            "type": "string",
            "description": "The email address of the invited user",
            "nullable": true
          },
          "token": {
            "type": "string",
            "description": "The invitation token",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TenantUserStatus"
          },
          "expiresOn": {
            "type": "string",
            "description": "When the invitation expires",
            "format": "date-time",
            "nullable": true
          },
          "acceptedAt": {
            "type": "string",
            "description": "When the invitation was accepted",
            "format": "date-time",
            "nullable": true
          },
          "declinedAt": {
            "type": "string",
            "description": "When the invitation was declined",
            "format": "date-time",
            "nullable": true
          },
          "isExpired": {
            "type": "boolean",
            "description": "Whether the invitation has expired"
          }
        },
        "additionalProperties": false,
        "description": "Response containing details about an invitation"
      },
      "InviteCodeDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique invite code string",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the invite code was created",
            "format": "date-time"
          },
          "isUsed": {
            "type": "boolean",
            "description": "Whether this invite code has been used to create a tenant"
          },
          "usedDate": {
            "type": "string",
            "description": "When the invite code was used (null if unused)",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents an invite code used to create new tenants in the system.\nInvite codes are generated by SuperAdmins and allocated to users who can then use them to register new organizations."
      },
      "InvoiceClientBillingLineItemsRequest": {
        "required": [
          "codes",
          "invoiceDate"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The line items to invoice. Pending lines are approved first; invoiced, cancelled and\nalready-submitted lines are refused."
          },
          "invoiceDate": {
            "type": "string",
            "description": "The date of the invoice. The lines keep their own billing dates.",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "Request to invoice several of a client's billing line items now, together on one invoice"
      },
      "InvoiceDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Platform-specific invoice identifier (unique within the accounting platform)",
            "nullable": true
          },
          "number": {
            "type": "string",
            "description": "Invoice number (as displayed in the accounting platform)",
            "nullable": true
          },
          "customerId": {
            "type": "string",
            "description": "Platform-specific customer identifier",
            "nullable": true
          },
          "customerName": {
            "type": "string",
            "description": "Customer/client name from the accounting platform",
            "nullable": true
          },
          "totalAmount": {
            "type": "number",
            "description": "Total invoice amount including tax",
            "format": "double"
          },
          "netAmount": {
            "type": "number",
            "description": "Net amount before tax",
            "format": "double"
          },
          "taxAmount": {
            "type": "number",
            "description": "Tax (VAT) amount",
            "format": "double"
          },
          "amountDue": {
            "type": "number",
            "description": "Outstanding amount still due (may be less than TotalAmount if partially paid)",
            "format": "double"
          },
          "date": {
            "type": "string",
            "description": "Invoice date (when the invoice was issued)",
            "format": "date-time"
          },
          "dueDate": {
            "type": "string",
            "description": "Payment due date (null if no due date specified)",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/InvoiceStatus"
          },
          "currency": {
            "type": "string",
            "description": "Invoice currency code (e.g., \"GBP\", \"USD\", \"EUR\")",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "description": "Direct link to view the invoice in the accounting platform",
            "nullable": true
          },
          "isPdfAvailable": {
            "type": "boolean",
            "description": "Whether a PDF can be downloaded for this invoice via the /pdf endpoint"
          },
          "platformData": {
            "type": "object",
            "additionalProperties": { },
            "description": "Platform-specific data that doesn't fit into the common model",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Invoice data retrieved from third-party accounting platforms (Xero, QuickBooks, FreeAgent, etc.).\nUsed for displaying client invoice information and tracking outstanding balances within Sodium."
      },
      "InvoiceDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "InvoiceLineItemResponse": {
        "required": [
          "applicationCode",
          "description"
        ],
        "type": "object",
        "properties": {
          "applicationCode": {
            "type": "string",
            "description": "The application that submitted this line item.",
            "nullable": true
          },
          "lineKey": {
            "type": "string",
            "description": "The application's key for the line set this line belongs to (PUT .../invoices/line-sets/{lineKey}).\nNull on a line sent before keyed line sets existed, and on an imported invoice's lines.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Description of the charge.",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "description": "Net amount in pounds.",
            "format": "double"
          },
          "quantity": {
            "type": "integer",
            "description": "Quantity of items.",
            "format": "int32"
          },
          "vatRate": {
            "type": "number",
            "description": "VAT rate as a percentage (e.g., 20.00).",
            "format": "double"
          },
          "vatAmount": {
            "type": "number",
            "description": "VAT amount in pounds.",
            "format": "double"
          },
          "periodStart": {
            "type": "string",
            "description": "Start date of the billing period.",
            "format": "date",
            "nullable": true
          },
          "periodEnd": {
            "type": "string",
            "description": "End date of the billing period.",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model representing a single line item on an invoice."
      },
      "InvoiceRecipient": {
        "required": [
          "email",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The recipient's name."
          },
          "email": {
            "minLength": 1,
            "type": "string",
            "description": "The recipient's email address.",
            "format": "email"
          }
        },
        "additionalProperties": false,
        "description": "Represents an additional invoice recipient."
      },
      "InvoiceResponse": {
        "required": [
          "code",
          "companyName",
          "invoiceNumber",
          "vatNumber"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code identifier for the invoice.",
            "nullable": true
          },
          "invoiceNumber": {
            "type": "string",
            "description": "The customer-facing invoice number (e.g., \"INV-000001\").",
            "nullable": true
          },
          "companyName": {
            "type": "string",
            "description": "The company name of the invoice issuer.",
            "nullable": true
          },
          "vatNumber": {
            "type": "string",
            "description": "The VAT registration number of the invoice issuer.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/BillingInvoiceStatus"
          },
          "subtotalAmount": {
            "type": "number",
            "description": "The subtotal amount (sum of line items net amounts) before VAT, in pounds.",
            "format": "double"
          },
          "vatAmount": {
            "type": "number",
            "description": "The total VAT amount (sum of line item VAT amounts) in pounds.",
            "format": "double"
          },
          "totalAmount": {
            "type": "number",
            "description": "The total amount of the invoice (subtotal + VAT) in pounds.",
            "format": "double"
          },
          "dueDate": {
            "type": "string",
            "description": "The date when payment is due.",
            "format": "date",
            "nullable": true
          },
          "paidDate": {
            "type": "string",
            "description": "The date and time when payment was received.",
            "format": "date-time",
            "nullable": true
          },
          "failureReason": {
            "type": "string",
            "description": "The reason for payment failure, if applicable.",
            "nullable": true
          },
          "pdfBlobUrl": {
            "type": "string",
            "description": "Time-limited URL for downloading the invoice PDF. Null if PDF has not been generated.",
            "nullable": true
          },
          "lineItems": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceLineItemResponse"
            },
            "description": "The line items included in this invoice.",
            "nullable": true
          },
          "invoiceDate": {
            "type": "string",
            "description": "The invoice date (UTC): when it was issued, or an imported invoice's own date. Null on a draft.",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When Account Hub created the record (a draft opens when its first line arrives).",
            "format": "date-time"
          },
          "sourceApplicationCode": {
            "type": "string",
            "description": "The application that raised an imported invoice, which Account Hub only records; null for\nAccount Hub's own invoices.",
            "nullable": true
          },
          "accountingInvoice": {
            "$ref": "#/components/schemas/AccountingLinkResponse"
          }
        },
        "additionalProperties": false,
        "description": "Response model representing an invoice with its line items."
      },
      "InvoiceStatus": {
        "enum": [
          "Unknown",
          "Draft",
          "Unpaid",
          "Paid",
          "Overdue",
          "Void",
          "PartiallyPaid"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "InvoiceSubmissionResult": {
        "type": "object",
        "properties": {
          "submittedCount": {
            "type": "integer",
            "format": "int32"
          },
          "failedCount": {
            "type": "integer",
            "format": "int32"
          },
          "skippedCount": {
            "type": "integer",
            "format": "int32"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "InvoiceSummaryResponse": {
        "required": [
          "code",
          "invoiceNumber"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code identifier for the invoice.",
            "nullable": true
          },
          "invoiceNumber": {
            "type": "string",
            "description": "The customer-facing invoice number.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/BillingInvoiceStatus"
          },
          "totalAmount": {
            "type": "number",
            "description": "The total amount of the invoice (subtotal + VAT) in pounds.",
            "format": "double"
          },
          "dueDate": {
            "type": "string",
            "description": "The date when payment is due.",
            "format": "date",
            "nullable": true
          },
          "pdfBlobUrl": {
            "type": "string",
            "description": "Time-limited URL for downloading the invoice PDF. Null if PDF has not been generated.",
            "nullable": true
          },
          "invoiceDate": {
            "type": "string",
            "description": "The invoice date (UTC): when it was issued, or an imported invoice's own date. Null on a draft.",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When Account Hub created the record (a draft opens when its first line arrives).",
            "format": "date-time"
          },
          "accountingInvoice": {
            "$ref": "#/components/schemas/AccountingLinkResponse"
          },
          "sourceApplicationCode": {
            "type": "string",
            "description": "The application that raised an imported invoice, which Account Hub only records; null for\nAccount Hub's own invoices.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Summary response model for listing invoices (without line items)."
      },
      "InvoiceSummaryResponsePagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceSummaryResponse"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ItsaStatusDetail": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/HmrcItsaStatus"
          },
          "statusReason": {
            "type": "string",
            "nullable": true
          },
          "businessIncomeTwoYearsPrior": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ItsaStatusResponse": {
        "type": "object",
        "properties": {
          "taxYear": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/HmrcItsaStatus"
          },
          "isInMtd": {
            "type": "boolean"
          },
          "taxYears": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItsaTaxYearStatus"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ItsaTaxYearStatus": {
        "type": "object",
        "properties": {
          "taxYear": {
            "type": "string",
            "nullable": true
          },
          "details": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItsaStatusDetail"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "KanbanStageCountDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The stage code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The stage name",
            "nullable": true
          },
          "icon": {
            "type": "string",
            "description": "Stage icon (Lucide icon name)",
            "nullable": true
          },
          "color": {
            "type": "string",
            "description": "Stage colour (hex)",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Display order of the stage on the board",
            "format": "int32"
          },
          "cardCount": {
            "type": "integer",
            "description": "Number of cards currently in this stage",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Per-stage card count for a kanban board, including the stage's display settings.\nOne row per stage on the board (stages with no cards are included with a count of 0).\nShared by service boards and sales pipeline boards."
      },
      "KanbanTaskDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The task code (for linking to the task page)",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The task name",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "dueDate": {
            "type": "string",
            "description": "The task due date. Used by the frontend to determine if the task is overdue.",
            "format": "date-time",
            "nullable": true
          },
          "currentStepName": {
            "type": "string",
            "description": "The current workflow step name (if the task has an active workflow).\nWhen present, this is more useful than the task name on kanban cards.",
            "nullable": true
          },
          "currentStepStatus": {
            "$ref": "#/components/schemas/TaskItemStatus"
          }
        },
        "additionalProperties": false,
        "description": "Lightweight task summary for kanban board cards"
      },
      "LateAccountingDateRuleDto": {
        "type": "object",
        "properties": {
          "isDisapplied": {
            "type": "boolean",
            "description": "True when the client has elected out of the automatic rule; false when the automatic\ntreatment stands."
          },
          "isEligible": {
            "type": "boolean",
            "description": "Whether this income source could disapply the rule at all — only businesses whose accounting\ndate falls between 31 March and 4 April inclusive are eligible."
          },
          "taxYearOfElection": {
            "type": "string",
            "description": "The first tax year the disapplication ran from, where the rule is disapplied.",
            "nullable": true
          },
          "taxYearElectionExpires": {
            "type": "string",
            "description": "The last tax year the disapplication covers — the election runs for five years.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The late accounting date rule (LADR) election HMRC hold for one self-employment income source\nand tax year.\n            \nThe automatic rule treats an accounting period ending between 31 March and 4 April as ending on\n5 April. Disapplying it means the 1–5 April profits are apportioned and reported separately\ninstead. Only a business whose accounting date falls in that window can elect at all, and the\nelection then stands for five years."
      },
      "LateAccountingDateRuleResponse": {
        "type": "object",
        "properties": {
          "isDisapplied": {
            "type": "boolean"
          },
          "isEligible": {
            "type": "boolean"
          },
          "taxYearOfElection": {
            "type": "string",
            "nullable": true
          },
          "taxYearElectionExpires": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LibraryPipelineImportItem": {
        "required": [
          "libraryCode"
        ],
        "type": "object",
        "properties": {
          "libraryCode": {
            "minLength": 1,
            "type": "string",
            "description": "The library code of the pipeline to import"
          },
          "name": {
            "type": "string",
            "description": "Optional: Override the name of the pipeline from the library template",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional: Override the description of the pipeline from the library template",
            "nullable": true
          },
          "defaultManagedByUserCode": {
            "type": "string",
            "description": "Optional: Code of the user who manages this pipeline's cards by default",
            "nullable": true
          },
          "nameSuffix": {
            "type": "string",
            "description": "Optional: Name suffix applied to the pipeline and every cascaded task/template on re-import\n(e.g. \"v2\"). When omitted and the pipeline was already imported, \"(N)\" is auto-generated.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single library pipeline to import, with its code and optional overrides"
      },
      "LibraryServiceImportItem": {
        "required": [
          "libraryCode"
        ],
        "type": "object",
        "properties": {
          "libraryCode": {
            "minLength": 1,
            "type": "string",
            "description": "The library code of the service to import"
          },
          "name": {
            "type": "string",
            "description": "Optional: Override the name of the service from the library template",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional: Override the description of the service from the library template",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "Optional: Override whether this service is archived (defaults to false)",
            "nullable": true
          },
          "accountingCode": {
            "maxLength": 20,
            "minLength": 0,
            "type": "string",
            "description": "Optional: Set the accounting code for this service (max 20 characters)",
            "nullable": true
          },
          "defaultManagedByUserCode": {
            "type": "string",
            "description": "Optional: Set the code of the user who is the default manager for this service",
            "nullable": true
          },
          "serviceScheduleContentCode": {
            "type": "string",
            "description": "Optional: Override the content block code for service schedule from library",
            "nullable": true
          },
          "proposalContentCode": {
            "type": "string",
            "description": "Optional: Override the content block code for proposals from library",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "Optional: Override the category of this service from the library template",
            "nullable": true
          },
          "pricing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServicePricingOptionDto"
            },
            "description": "Optional: Override the pricing options from the library template",
            "nullable": true
          },
          "pricingFactors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PricingFactorDto"
            },
            "description": "Optional: Override the pricing factors from the library template",
            "nullable": true
          },
          "nameSuffix": {
            "type": "string",
            "description": "Optional suffix appended to the service name and all related recurring and onboarding tasks names on re-import\n(e.g. \"v2\", \"May 2026\"). When omitted and the tenant already has a copy of this library\nservice, the next available \"(N)\" suffix will be used.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single library service to import, with its code and optional overrides"
      },
      "LibraryStatus": {
        "enum": [
          "NotFromLibrary",
          "UpToDate",
          "LocallyModified",
          "LibraryUpdated"
        ],
        "type": "string",
        "description": "Describes a library-imported entity's relationship to its source library template.",
        "example": "NotFromLibrary"
      },
      "LibraryTaskTemplateImportItem": {
        "required": [
          "libraryCode"
        ],
        "type": "object",
        "properties": {
          "libraryCode": {
            "minLength": 1,
            "type": "string",
            "description": "The library code of the task template to import"
          },
          "nameSuffix": {
            "type": "string",
            "description": "Optional name suffix applied when the tenant already has a copy of this template\n(e.g. \"v2\"). When omitted, a \"(N)\" suffix is generated automatically.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single library task template to import"
      },
      "LibraryWorkflowImportItem": {
        "required": [
          "libraryCode"
        ],
        "type": "object",
        "properties": {
          "libraryCode": {
            "minLength": 1,
            "type": "string",
            "description": "The library code of the workflow to import."
          },
          "nameSuffix": {
            "type": "string",
            "description": "Optional suffix appended to the workflow name on re-import (e.g. \"v2\", \"May 2026\").\nWhen omitted and the tenant already has a copy of this library workflow, the next\navailable \"(N)\" suffix is used.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single library workflow to import, with its code and optional name suffix."
      },
      "LifetimeAllowances": {
        "type": "object",
        "properties": {
          "lifetimeAllowanceBadr": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "lifetimeAllowanceInv": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LinkClientBookkeepingRequest": {
        "required": [
          "externalOrgId"
        ],
        "type": "object",
        "properties": {
          "externalOrgId": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "The organisation's identifier at the provider. Must be one of the codes returned by the\navailable-organisations endpoint."
          }
        },
        "additionalProperties": false,
        "description": "Binds a client to one organisation at the practice's bookkeeping-health provider."
      },
      "LinkClientBooksRequest": {
        "required": [
          "externalOrgId",
          "thirdPartyConnectionCode"
        ],
        "type": "object",
        "properties": {
          "thirdPartyConnectionCode": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The connection whose credentials reach the organisation. Must be one of the codes returned by\nthe available-organisations endpoint."
          },
          "externalOrgId": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "The organisation's identifier at the accounting platform."
          }
        },
        "additionalProperties": false,
        "description": "Binds a client to one organisation in their own accounting software, reached through an\nexisting connection."
      },
      "LinkClientCisManagerOrganisationRequest": {
        "required": [
          "organisationCode"
        ],
        "type": "object",
        "properties": {
          "organisationCode": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The organisation's code in CIS Manager, from the client's linkable organisations"
          }
        },
        "additionalProperties": false,
        "description": "Links a client to a CIS Manager organisation the signed-in user already has"
      },
      "LinkConversationClientRequest": {
        "required": [
          "clientCode"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the client to link"
          }
        },
        "additionalProperties": false,
        "description": "Request to link a client to a conversation"
      },
      "LinkConversationTaskRequest": {
        "required": [
          "taskItemCode"
        ],
        "type": "object",
        "properties": {
          "taskItemCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the task to link"
          }
        },
        "additionalProperties": false,
        "description": "Request to link a task to a conversation: an email one, or a message one (SMS and WhatsApp)"
      },
      "LinkType": {
        "enum": [
          "Other",
          "Website",
          "LinkedIn",
          "Instagram",
          "Facebook",
          "Twitter"
        ],
        "type": "string",
        "example": "Other"
      },
      "LinkableCisOrganisationDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The organisation's code in CIS Manager (its subdomain)",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "inPractice": {
            "type": "boolean",
            "description": "The practice runs it already; false for one the user owns outside it, which linking adds to the practice"
          },
          "employerPayeReference": {
            "type": "string",
            "description": "Its employer PAYE reference in CIS Manager",
            "nullable": true
          },
          "accountsOfficeReference": {
            "type": "string",
            "description": "Its Accounts Office reference in CIS Manager",
            "nullable": true
          },
          "utr": {
            "type": "string",
            "description": "Its UTR in CIS Manager",
            "nullable": true
          },
          "match": {
            "$ref": "#/components/schemas/CisOrganisationMatch"
          }
        },
        "additionalProperties": false,
        "description": "A CIS Manager organisation the signed-in user already has, which a client with no CIS Manager account could be\nlinked to instead of creating another"
      },
      "LinkedWorkflowStepDto": {
        "type": "object",
        "properties": {
          "groupNumber": {
            "type": "integer",
            "description": "The group number of the step within the task's workflow",
            "format": "int32"
          },
          "stepNumber": {
            "type": "integer",
            "description": "The step number within the group",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "description": "The name of the step",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A workflow step linked from a time entry or running timer. Steps have no public code —\nthey are identified within their task by group number and step number."
      },
      "ListEmailsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailSummaryDto"
            },
            "description": "List of email summaries for the current page",
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "description": "Total number of emails matching the filter criteria",
            "format": "int32"
          },
          "offset": {
            "type": "integer",
            "description": "Number of records skipped (pagination offset)",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "description": "Maximum number of records returned per page",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean",
            "description": "Indicates if there are more records available beyond this page"
          }
        },
        "additionalProperties": false,
        "description": "Paginated response for listing emails"
      },
      "LocaleMetadata": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "dateExample": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LossCarryBack": {
        "type": "object",
        "properties": {
          "previousYearGeneralIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "earlyYearLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "terminalLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LossCarryForward": {
        "type": "object",
        "properties": {
          "currentYearLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "previousYearsLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LossCarrySideways": {
        "type": "object",
        "properties": {
          "currentYearGeneralIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LossClaim": {
        "type": "object",
        "properties": {
          "claimId": {
            "type": "string",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "nullable": true
          },
          "typeOfLoss": {
            "$ref": "#/components/schemas/HmrcLossType"
          },
          "typeOfClaim": {
            "$ref": "#/components/schemas/HmrcLossClaimType"
          },
          "taxYearClaimedFor": {
            "type": "string",
            "nullable": true
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "lastModified": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "LossClaimOrderItem": {
        "type": "object",
        "properties": {
          "claimId": {
            "type": "string",
            "nullable": true
          },
          "sequence": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "LossClaims": {
        "type": "object",
        "properties": {
          "carryBack": {
            "$ref": "#/components/schemas/LossCarryBack"
          },
          "carrySideways": {
            "$ref": "#/components/schemas/LossCarrySideways"
          },
          "preferenceOrder": {
            "$ref": "#/components/schemas/LossPreferenceOrder"
          },
          "carryForward": {
            "$ref": "#/components/schemas/LossCarryForward"
          }
        },
        "additionalProperties": false
      },
      "LossPreferenceOrder": {
        "type": "object",
        "properties": {
          "applyFirst": {
            "$ref": "#/components/schemas/HmrcLossPreferenceOrder"
          }
        },
        "additionalProperties": false
      },
      "LossesAndClaims": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "claims": {
            "$ref": "#/components/schemas/LossClaims"
          },
          "losses": {
            "$ref": "#/components/schemas/LossesBroughtForward"
          }
        },
        "additionalProperties": false
      },
      "LossesBroughtForward": {
        "type": "object",
        "properties": {
          "broughtForwardLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LumpSumAmount": {
        "type": "object",
        "properties": {
          "amount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxTakenOffInEmployment": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "MailboxAttachmentDto": {
        "type": "object",
        "properties": {
          "attachmentId": {
            "type": "string",
            "description": "Provider-specific attachment ID",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "description": "File name",
            "nullable": true
          },
          "contentType": {
            "type": "string",
            "description": "MIME content type",
            "nullable": true
          },
          "size": {
            "type": "integer",
            "description": "Size in bytes",
            "format": "int64"
          },
          "contentId": {
            "type": "string",
            "description": "Content ID for inline attachments (CID reference used in HTML body).\nNull for regular (non-inline) attachments.",
            "nullable": true
          },
          "isInline": {
            "type": "boolean",
            "description": "Whether this attachment is inline (embedded in the HTML body via CID reference)"
          }
        },
        "additionalProperties": false,
        "description": "Attachment metadata from the provider"
      },
      "MailboxConversationSortField": {
        "enum": [
          "LatestMessageDate",
          "Subject",
          "MessageCount"
        ],
        "type": "string",
        "description": "Specifies the field to sort mailbox conversations by in list queries",
        "example": "LatestMessageDate"
      },
      "MailboxEmailDirection": {
        "enum": [
          "Inbound",
          "Outbound"
        ],
        "type": "string",
        "description": "Represents the direction of an email in the external mailbox",
        "example": "Inbound"
      },
      "MailboxFolderScope": {
        "enum": [
          "Received",
          "AllExceptJunk"
        ],
        "type": "string",
        "description": "A named set of folders to list mail from, resolved per mailbox. Where systemFolderType matches\none kind of system folder, a scope spans every folder that fits its rule, wherever the user\nhas filed the mail.",
        "example": "Received"
      },
      "MailboxMessageSortField": {
        "enum": [
          "MessageDate",
          "Subject",
          "Sender"
        ],
        "type": "string",
        "description": "Specifies the field to sort mailbox messages by in list queries",
        "example": "MessageDate"
      },
      "MailboxReadSharing": {
        "enum": [
          "Private",
          "Everyone",
          "Selected"
        ],
        "type": "string",
        "example": "Private"
      },
      "MailboxShareRuleDto": {
        "type": "object",
        "properties": {
          "uniqueId": {
            "type": "string",
            "description": "Rule identifier, used to delete the rule.",
            "format": "uuid"
          },
          "kind": {
            "$ref": "#/components/schemas/MailboxShareRuleKind"
          },
          "value": {
            "type": "string",
            "description": "The matched value: a lowercased address or domain, a conversation id, or a folder UniqueId as text.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the rule was created (UTC).",
            "format": "date-time"
          },
          "isExclusion": {
            "type": "boolean",
            "description": "False shares what the rule matches; true hides it from everyone but the owner, in both\nsharing modes. Exclusions win over shares."
          }
        },
        "additionalProperties": false,
        "description": "One share rule on a mailbox configuration."
      },
      "MailboxShareRuleKind": {
        "enum": [
          "Address",
          "Domain",
          "Conversation",
          "Folder",
          "Message"
        ],
        "type": "string",
        "description": "What a mailbox share rule matches on. A share rule grants shared-access callers every message\nin the mailbox that matches it; an exclusion rule hides every message that matches it from\neveryone but the owner. Both are evaluated live at query time.",
        "example": "Address"
      },
      "MailboxThreadSummaryDto": {
        "type": "object",
        "properties": {
          "conversationId": {
            "type": "string",
            "description": "Conversation ID (used in URL routes and to fetch conversation messages)",
            "nullable": true
          },
          "subject": {
            "type": "string",
            "description": "Subject of the latest message in the thread",
            "nullable": true
          },
          "snippet": {
            "type": "string",
            "description": "Snippet/preview of the latest message in the thread",
            "nullable": true
          },
          "latestMessageDate": {
            "type": "string",
            "description": "Date of the latest message in the thread",
            "format": "date-time"
          },
          "latestFromEmail": {
            "type": "string",
            "description": "Sender email of the latest message",
            "nullable": true
          },
          "latestFromName": {
            "type": "string",
            "description": "Sender display name of the latest message",
            "nullable": true
          },
          "messageCount": {
            "type": "integer",
            "description": "Total number of messages in the thread",
            "format": "int32"
          },
          "unreadCount": {
            "type": "integer",
            "description": "Number of unread messages in the thread",
            "format": "int32"
          },
          "hasAttachments": {
            "type": "boolean",
            "description": "Whether any message in the thread has attachments"
          },
          "hasDraft": {
            "type": "boolean",
            "description": "Whether the thread holds a draft the caller can read, whichever folder the list is showing"
          },
          "importance": {
            "$ref": "#/components/schemas/EmailImportance"
          },
          "latestMessageUniqueId": {
            "type": "string",
            "description": "UniqueId of the latest message (useful for navigating to it)",
            "format": "uuid"
          },
          "configCode": {
            "type": "string",
            "description": "Configuration code (GUID) identifying which mailbox this thread belongs to",
            "nullable": true
          },
          "folders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Folders/labels that any message in this thread currently belongs to: the union across every\nmessage of the conversation the caller can read, whatever folder the list is showing. Each\nentry's `Code` is the folder's UniqueId and `Name` is the display path.",
            "nullable": true
          },
          "triageStatusCode": {
            "type": "string",
            "description": "The conversation's effective triage status code: its own, otherwise the history code for a\nconversation older than the moment triage was switched on (when the caller passed one),\notherwise the mailbox default. Null when the mailbox has triage off.",
            "nullable": true
          },
          "triageAssigneeCode": {
            "type": "string",
            "description": "Who the conversation is assigned to; null when unassigned or the mailbox has triage off.",
            "nullable": true
          },
          "triageIsMatched": {
            "type": "boolean",
            "description": "The caller's verdict: true when a known client is involved, false when none is, null when not\nknown yet (it then lists under Unmatched) or the mailbox has triage off.",
            "nullable": true
          },
          "triageBringBackAt": {
            "type": "string",
            "description": "When a pending bring back moves the conversation to another status (UTC); null when none is\npending or the mailbox has triage off.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Summary DTO for a mailbox conversation (one entry per conversation in list views)"
      },
      "MailboxThreadSummaryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MailboxThreadSummaryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "MailingListSubscriptionDto": {
        "required": [
          "email"
        ],
        "type": "object",
        "properties": {
          "email": {
            "minLength": 1,
            "type": "string",
            "format": "email"
          },
          "fullName": {
            "type": "string",
            "nullable": true
          },
          "practiceName": {
            "type": "string",
            "nullable": true
          },
          "redirectUrl": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "MaintenancePayment": {
        "type": "object",
        "properties": {
          "customerReference": {
            "type": "string",
            "nullable": true
          },
          "exSpouseName": {
            "type": "string",
            "nullable": true
          },
          "exSpouseDateOfBirth": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "MandateDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "reference": {
            "type": "string",
            "nullable": true
          },
          "payerId": {
            "type": "string",
            "nullable": true
          },
          "payerName": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "scheme": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "authorizationUrl": {
            "type": "string",
            "nullable": true
          },
          "webUrl": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a direct debit mandate"
      },
      "MandateSetupResponse": {
        "required": [
          "redirectUrl"
        ],
        "type": "object",
        "properties": {
          "redirectUrl": {
            "type": "string",
            "description": "The GoCardless URL to redirect the user to for mandate authorisation.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model returned when initiating a GoCardless mandate setup.\nContains the URL to redirect the user to for authorisation."
      },
      "MandateSummaryResponse": {
        "required": [
          "status"
        ],
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/PaymentMandateStatus"
          },
          "scheme": {
            "type": "string",
            "description": "The Direct Debit scheme (e.g., \"bacs\", \"sepa_core\").",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the mandate was created.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Summary of the active or most recent payment mandate for a billing account."
      },
      "MapExternalClientRequest": {
        "required": [
          "clientCode",
          "externalClientId"
        ],
        "type": "object",
        "properties": {
          "externalClientId": {
            "minLength": 1,
            "type": "string",
            "description": "The external platform's client ID"
          },
          "clientCode": {
            "minLength": 1,
            "type": "string",
            "description": "The Sodium client code to map to"
          }
        },
        "additionalProperties": false,
        "description": "Request to manually map an external platform client to an existing Sodium client"
      },
      "MarginsDto": {
        "type": "object",
        "properties": {
          "top": {
            "type": "number",
            "description": "Top margin in millimeters (default: 25mm)",
            "format": "float"
          },
          "bottom": {
            "type": "number",
            "description": "Bottom margin in millimeters (default: 25mm)",
            "format": "float"
          },
          "left": {
            "type": "number",
            "description": "Left margin in millimeters (default: 20mm)",
            "format": "float"
          },
          "right": {
            "type": "number",
            "description": "Right margin in millimeters (default: 20mm)",
            "format": "float"
          }
        },
        "additionalProperties": false,
        "description": "Page margin configuration for generated documents.\nAll measurements are in millimeters."
      },
      "MaritalStatus": {
        "enum": [
          "Single",
          "Married",
          "CivilPartnership",
          "Divorced",
          "Widowed",
          "Separated"
        ],
        "type": "string",
        "example": "Single"
      },
      "MarkNotificationsSeenRequest": {
        "required": [
          "upToId"
        ],
        "type": "object",
        "properties": {
          "upToId": {
            "minLength": 1,
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "MatchContactsPersonRequest": {
        "required": [
          "reference"
        ],
        "type": "object",
        "properties": {
          "reference": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "Caller's own identifier for this person, echoed back on the result so the answers can be\nlined up with the list that was sent."
          },
          "firstName": {
            "maxLength": 100,
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "maxLength": 100,
            "type": "string",
            "nullable": true
          },
          "companiesHouseOfficerId": {
            "maxLength": 50,
            "type": "string",
            "description": "Companies House's identifier for this person, when they came from the officer register.\nThe one signal that identifies somebody with certainty.",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "description": "The person's date of birth. Only the month and year are compared, so the partial date\nCompanies House publishes (day set to 1) is fine here.",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One person to look for among the practice's existing contacts."
      },
      "MatchContactsRequest": {
        "required": [
          "people"
        ],
        "type": "object",
        "properties": {
          "people": {
            "maxItems": 200,
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MatchContactsPersonRequest"
            },
            "description": "The people to look up. Typically a company's officers and PSCs, straight off the\nCompanies House register."
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for asking which of a batch of people the practice already holds as contacts."
      },
      "MatchMessagingConversationRequest": {
        "type": "object",
        "properties": {
          "contactCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The contact's code",
            "nullable": true
          },
          "clientCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The client's code. With a contact, the contact must be on this client.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What to match a conversation to: a contact, a client, or a contact on one of its clients"
      },
      "MaterialiseProjectedTaskRequest": {
        "type": "object",
        "properties": {
          "projectedTaskCode": {
            "type": "string",
            "description": "The composite code of the projected task to materialise\nFormat: proj-{recurringTaskCode}-{clientCode}-{yyyyMMdd}",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to materialise a projected task into a saved task"
      },
      "MaterialisedProjectedTaskDto": {
        "type": "object",
        "properties": {
          "taskCode": {
            "type": "string",
            "description": "The code of the real task the projected occurrence became",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Returned with 410 Gone when a projected task has already been created as a real task"
      },
      "MeetingMedium": {
        "enum": [
          "InPerson",
          "Video",
          "Phone"
        ],
        "type": "string",
        "example": "InPerson"
      },
      "MeetingNoteAttendeeDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The contact's or user's code; null once they have been deleted",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Their name when they were recorded",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A contact or member of staff recorded as attending a meeting"
      },
      "MeetingNoteDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this meeting note",
            "nullable": true
          },
          "title": {
            "type": "string",
            "description": "Short plain-text title, e.g. \"Missed call from Jane Smith\"",
            "nullable": true
          },
          "externalPlatform": {
            "type": "string",
            "description": "The note taker the note was imported from (a platform key, e.g. \"Granola\"), or null for a note written in\nSodium or pushed through the API. The platform's icon is in the third-party platforms metadata.",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "When the meeting started, UTC",
            "format": "date-time"
          },
          "endTime": {
            "type": "string",
            "description": "When the meeting ended, UTC; null if not recorded",
            "format": "date-time",
            "nullable": true
          },
          "medium": {
            "$ref": "#/components/schemas/MeetingMedium"
          },
          "summary": {
            "type": "string",
            "description": "Summary, HTML",
            "nullable": true
          },
          "content": {
            "type": "string",
            "description": "The full content, usually a transcript, HTML. Returned by get by code only; always null on a list.",
            "nullable": true
          },
          "taskItem": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "contacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MeetingNoteAttendeeDto"
            },
            "description": "The client contacts who attended. A deleted contact has a name and no code.",
            "nullable": true
          },
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MeetingNoteAttendeeDto"
            },
            "description": "The staff who attended. A deleted user has a name and no code.",
            "nullable": true
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MeetingNoteLinkDto"
            },
            "description": "Links to outside resources, such as the recording, in the order given",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the meeting note was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the meeting note was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A record of a meeting or call with a client"
      },
      "MeetingNoteDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MeetingNoteDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "MeetingNoteLinkDto": {
        "required": [
          "name",
          "url"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "What the link is, e.g. \"Recording\""
          },
          "url": {
            "maxLength": 2048,
            "minLength": 1,
            "type": "string",
            "description": "The address, http or https. Opened in a new tab; never downloaded or proxied."
          }
        },
        "additionalProperties": false,
        "description": "A link from a meeting note to an outside resource, such as the recording"
      },
      "MeetingNoteSortField": {
        "enum": [
          "StartTime",
          "UpdatedDate"
        ],
        "type": "string",
        "example": "StartTime"
      },
      "MeetingNotesWebhookSecretRequest": {
        "type": "object",
        "properties": {
          "signingSecret": {
            "maxLength": 200,
            "type": "string",
            "description": "The secret as the note taker shows it. Blank clears the stored one, after which every delivery is refused.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The signing secret a note taker made for a webhook the practice set up by hand on its site (Circleback)."
      },
      "MeetingNotesWebhookSetupDto": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "The address the note taker should send events to.",
            "nullable": true
          },
          "signingSecret": {
            "type": "string",
            "description": "The secret Sodium made for the note taker to sign events with (Fireflies). Null when the note taker makes its own\n(Circleback): Sodium never shows that one back.",
            "nullable": true
          },
          "secretIsFromPlatform": {
            "type": "boolean",
            "description": "Whether the note taker makes the signing secret, for the practice to paste into Sodium, rather than the other way\nround."
          },
          "hasSigningSecret": {
            "type": "boolean",
            "description": "Whether Sodium holds a signing secret. Deliveries are refused until it does."
          },
          "lastDeliveredAt": {
            "type": "string",
            "description": "When Sodium last received a delivery, including a test, or null when it never has. Sodium cannot ask the note\ntaker whether the webhook exists, so this is the only sign that it does.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a practice pastes into a note taker that cannot have its webhook registered for it (Fireflies, Circleback)."
      },
      "MergeContactRequest": {
        "required": [
          "contact",
          "mergedContactCodes"
        ],
        "type": "object",
        "properties": {
          "mergedContactCodes": {
            "maxItems": 5,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The contacts to merge into the kept contact, 1 to 5. They are permanently deleted once the merge completes."
          },
          "contact": {
            "$ref": "#/components/schemas/UpdateContactRequest"
          }
        },
        "additionalProperties": false,
        "description": "Request to merge contacts into this (kept) contact."
      },
      "MessageChannel": {
        "enum": [
          "Sms",
          "WhatsApp"
        ],
        "type": "string",
        "example": "Sms"
      },
      "MessageDirection": {
        "enum": [
          "Inbound",
          "Outbound"
        ],
        "type": "string",
        "example": "Inbound"
      },
      "MessageStatus": {
        "enum": [
          "Queued",
          "Sending",
          "Sent",
          "Delivered",
          "Read",
          "Undelivered",
          "Failed",
          "Received"
        ],
        "type": "string",
        "example": "Queued"
      },
      "MessagingAutoTopUpDto": {
        "type": "object",
        "properties": {
          "below": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "The balance, in credits, below which a top-up is bought",
            "format": "int32"
          },
          "blocks": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "Blocks bought each time",
            "format": "int32"
          },
          "monthlyCapBlocks": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "The most blocks bought automatically in a calendar month; at least SodiumHQ.DTOs.Messaging.MessagingAutoTopUpDto.Blocks",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Automatic top-up: when a send leaves fewer than SodiumHQ.DTOs.Messaging.MessagingAutoTopUpDto.Below credits, buy SodiumHQ.DTOs.Messaging.MessagingAutoTopUpDto.Blocks blocks of\ncredits, at most SodiumHQ.DTOs.Messaging.MessagingAutoTopUpDto.MonthlyCapBlocks blocks in a calendar month"
      },
      "MessagingAvailableNumberDto": {
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string",
            "description": "E.164",
            "nullable": true
          },
          "friendlyName": {
            "type": "string",
            "description": "As the provider formats it for display",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A number the practice may choose"
      },
      "MessagingConversationDetailDto": {
        "type": "object",
        "properties": {
          "conversation": {
            "$ref": "#/components/schemas/MessagingConversationDto"
          },
          "messages": {
            "$ref": "#/components/schemas/MessagingMessageDtoPagedResult"
          },
          "taskAssociations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The tasks linked to the conversation, newest link first, as an email conversation's taskAssociations",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A conversation with one page of its messages, newest first"
      },
      "MessagingConversationDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The conversation's code",
            "nullable": true
          },
          "externalAddress": {
            "type": "string",
            "description": "The other party's number, E.164",
            "nullable": true
          },
          "contact": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "isAmbiguous": {
            "type": "boolean",
            "description": "The number was on more than one record when it was last matched automatically; see candidates"
          },
          "matchedByUserName": {
            "type": "string",
            "description": "Who matched or unmatched it by hand; null when its match is automatic",
            "nullable": true
          },
          "matchedDate": {
            "type": "string",
            "description": "When it was matched or unmatched by hand",
            "format": "date-time",
            "nullable": true
          },
          "dismissedByUserName": {
            "type": "string",
            "description": "Who dismissed it from the inbox",
            "nullable": true
          },
          "dismissedDate": {
            "type": "string",
            "description": "When it was dismissed from the inbox; null while it is not",
            "format": "date-time",
            "nullable": true
          },
          "lastMessageDate": {
            "type": "string",
            "description": "When its newest message arrived or was sent",
            "format": "date-time"
          },
          "whatsAppWindowClosesAt": {
            "type": "string",
            "description": "When WhatsApp free text to the number stops being allowed, as the Messaging Service stated it (24 hours after\nthe number's newest inbound WhatsApp message); null when closed or never opened, so only a template can go. A\nhint for offering a template: the service decides, and refuses free text outside the window with a 409.",
            "format": "date-time",
            "nullable": true
          },
          "isKnownOnWhatsApp": {
            "type": "boolean",
            "description": "The number is known on WhatsApp (it has messaged the practice on WhatsApp, or a WhatsApp message to it was\ndelivered or read, and none has failed since because it is not on WhatsApp): the WhatsApp icon beside it"
          },
          "hasUnread": {
            "type": "boolean",
            "description": "Someone in the practice has yet to read its newest inbound message. Practice-wide, not per user:\ncleared by its read route (or the client's), a send on it, or dismissing it."
          },
          "lastReadDate": {
            "type": "string",
            "description": "When it was last marked read; null when it never has been",
            "format": "date-time",
            "nullable": true
          },
          "messageCount": {
            "type": "integer",
            "description": "How many messages it holds, from the Messaging Service; 0 when the service could not be read",
            "format": "int32"
          },
          "lastMessage": {
            "$ref": "#/components/schemas/MessagingMessageDto"
          },
          "candidates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessagingMatchCandidateDto"
            },
            "description": "For an ambiguous conversation in the inbox: the contacts and clients holding its number. Empty otherwise.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A conversation with one outside number, across SMS and WhatsApp. It is to sort while it has no\ncontact, no client and has not been dismissed."
      },
      "MessagingConversationDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessagingConversationDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "MessagingConversationView": {
        "enum": [
          "ToSort",
          "All",
          "Dismissed",
          "Matched"
        ],
        "type": "string",
        "example": "ToSort"
      },
      "MessagingCreditPricesDto": {
        "type": "object",
        "properties": {
          "numberMonthlyPence": {
            "type": "integer",
            "description": "The practice's own number, a month",
            "format": "int32"
          },
          "creditBlockPence": {
            "type": "integer",
            "description": "One block of credits",
            "format": "int32"
          },
          "creditsPerBlock": {
            "type": "integer",
            "description": "Credits in a block",
            "format": "int32"
          },
          "creditsPerSmsSegment": {
            "type": "integer",
            "description": "Credits one SMS segment costs",
            "format": "int32"
          },
          "creditsPerWhatsAppMessage": {
            "type": "integer",
            "description": "Credits one WhatsApp message costs",
            "format": "int32"
          },
          "maxBlocksPerPurchase": {
            "type": "integer",
            "description": "The most blocks one purchase may buy",
            "format": "int32"
          },
          "numberMonthlyPenceOverride": {
            "type": "integer",
            "description": "Sodium's price for this practice's number; null when it pays the default",
            "format": "int32",
            "nullable": true
          },
          "creditBlockPenceOverride": {
            "type": "integer",
            "description": "Sodium's block price for this practice; null when it pays the default",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What messaging costs the practice, in pence ex VAT"
      },
      "MessagingCreditPurchaseDto": {
        "type": "object",
        "properties": {
          "requestId": {
            "type": "string",
            "description": "The purchase's id: the request id it was made with (an automatic top-up's is the service's)",
            "format": "uuid"
          },
          "blocks": {
            "type": "integer",
            "description": "Blocks bought",
            "format": "int32"
          },
          "credits": {
            "type": "integer",
            "description": "Credits bought",
            "format": "int32"
          },
          "blockPricePence": {
            "type": "integer",
            "description": "The block price paid, pence ex VAT",
            "format": "int32"
          },
          "amountPence": {
            "type": "integer",
            "description": "Blocks × block price, pence ex VAT",
            "format": "int32"
          },
          "source": {
            "$ref": "#/components/schemas/MessagingCreditPurchaseSource"
          },
          "purchasedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When it was bought",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "One purchase of messaging credits"
      },
      "MessagingCreditPurchaseDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessagingCreditPurchaseDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "MessagingCreditPurchaseSource": {
        "enum": [
          "Manual",
          "AutoTopUp"
        ],
        "type": "string",
        "example": "Manual"
      },
      "MessagingCreditsDto": {
        "type": "object",
        "properties": {
          "balance": {
            "type": "integer",
            "description": "Credits left",
            "format": "int32"
          },
          "autoTopUp": {
            "$ref": "#/components/schemas/MessagingAutoTopUpDto"
          },
          "lowCreditAlertBelow": {
            "type": "integer",
            "description": "The balance below which the practice's messaging admins are told; null when off",
            "format": "int32",
            "nullable": true
          },
          "prices": {
            "$ref": "#/components/schemas/MessagingCreditPricesDto"
          },
          "creditsUsedThisMonth": {
            "type": "integer",
            "description": "Credits spent this calendar month (UTC), less any given back for a send that failed",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The practice's messaging credits: one SMS segment or one WhatsApp message costs one credit. Read from the Messaging\nService each time; SodiumHQ keeps no copy."
      },
      "MessagingDoNotTextContactDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The contact's code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The contact's name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A contact whose mobile is a number on the do-not-text list"
      },
      "MessagingDoNotTextEntryDto": {
        "type": "object",
        "properties": {
          "source": {
            "$ref": "#/components/schemas/MessagingDoNotTextSource"
          },
          "addedDate": {
            "type": "string",
            "description": "When it was added (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "One channel's entry for a number on the do-not-text list"
      },
      "MessagingDoNotTextNumberDto": {
        "type": "object",
        "properties": {
          "address": {
            "type": "string",
            "description": "The number, E.164",
            "nullable": true
          },
          "sms": {
            "$ref": "#/components/schemas/MessagingDoNotTextEntryDto"
          },
          "whatsApp": {
            "$ref": "#/components/schemas/MessagingDoNotTextEntryDto"
          },
          "contacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessagingDoNotTextContactDto"
            },
            "description": "The contacts whose mobile is the number, by name; empty when it is on no contact",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A number and its place on the practice's do-not-text list (the Messaging Service's opt-out list), per channel, with\nthe contacts whose mobile it is. A channel's entry is null when messages on it are not stopped; both null means the\nnumber is not on the list. Read fresh from the service on every call."
      },
      "MessagingDoNotTextSource": {
        "enum": [
          "Stop",
          "Practice"
        ],
        "type": "string",
        "example": "Stop"
      },
      "MessagingMatchCandidateDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The contact's or client's code",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/MessagingMatchCandidateType"
          },
          "name": {
            "type": "string",
            "description": "The contact's or client's name",
            "nullable": true
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "For a contact: the clients it belongs to",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A contact or client holding an ambiguous conversation's number"
      },
      "MessagingMatchCandidateType": {
        "enum": [
          "Contact",
          "Client"
        ],
        "type": "string",
        "example": "Contact"
      },
      "MessagingMessageDto": {
        "type": "object",
        "properties": {
          "messageId": {
            "type": "string",
            "description": "The message's id in the Messaging Service",
            "format": "uuid"
          },
          "conversationCode": {
            "type": "string",
            "description": "The code of the conversation it belongs to",
            "nullable": true
          },
          "externalAddress": {
            "type": "string",
            "description": "The other party's number, E.164",
            "nullable": true
          },
          "contact": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "direction": {
            "$ref": "#/components/schemas/MessageDirection"
          },
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "tenantAddress": {
            "type": "string",
            "description": "The practice's own number on the message, E.164",
            "nullable": true
          },
          "body": {
            "type": "string",
            "description": "The text; empty for a media-only message",
            "nullable": true
          },
          "contentSid": {
            "type": "string",
            "description": "The WhatsApp template sent (HX…); null for free text and inbound messages",
            "nullable": true
          },
          "template": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "status": {
            "$ref": "#/components/schemas/MessageStatus"
          },
          "errorCode": {
            "type": "integer",
            "description": "The provider's error code when it failed or was not delivered",
            "format": "int32",
            "nullable": true
          },
          "errorMessage": {
            "type": "string",
            "description": "The provider's error text when sending was refused",
            "nullable": true
          },
          "sentByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "sentByWorkflow": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "sentByBroadcast": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "isSentByChase": {
            "type": "boolean",
            "description": "The daily chase sent it, shown as \"Sent by chase\": the practice texts its chases"
          },
          "messageDate": {
            "type": "string",
            "description": "When the Messaging Service stored it (UTC)",
            "format": "date-time"
          },
          "media": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessagingMessageMediaDto"
            },
            "description": "Its attachments",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One SMS or WhatsApp message, inbound or outbound"
      },
      "MessagingMessageDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessagingMessageDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "MessagingMessageMediaDto": {
        "type": "object",
        "properties": {
          "mediaIndex": {
            "type": "integer",
            "description": "Its position on the message, from 0",
            "format": "int32"
          },
          "contentType": {
            "type": "string",
            "description": "MIME type, e.g. image/jpeg",
            "nullable": true
          },
          "size": {
            "type": "integer",
            "description": "Size in bytes, once the Messaging Service holds its copy",
            "format": "int64",
            "nullable": true
          },
          "isCopied": {
            "type": "boolean",
            "description": "Whether the Messaging Service holds its own copy of the file"
          },
          "url": {
            "type": "string",
            "description": "Where SodiumHQ streams the file from (this API, with the caller's token), or null until the\nMessaging Service holds its copy",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An attachment on a message. The file is served at SodiumHQ.DTOs.Messaging.MessagingMessageMediaDto.Url once the Messaging Service holds\nits copy."
      },
      "MessagingMessageStatusDto": {
        "type": "object",
        "properties": {
          "messageId": {
            "type": "string",
            "description": "The message's id in the Messaging Service",
            "format": "uuid"
          },
          "status": {
            "$ref": "#/components/schemas/MessageStatus"
          },
          "conversationCode": {
            "type": "string",
            "description": "The code of the conversation the message is on",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A message's live status in the Messaging Service and the conversation it is on (a task's text step shows them)"
      },
      "MessagingNumberApplicationAddressDto": {
        "required": [
          "city",
          "isoCountry",
          "postalCode",
          "street"
        ],
        "type": "object",
        "properties": {
          "street": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The first line"
          },
          "streetSecondary": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The second line, if any",
            "nullable": true
          },
          "city": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The town or city"
          },
          "region": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The county or region, if any",
            "nullable": true
          },
          "postalCode": {
            "maxLength": 20,
            "minLength": 0,
            "type": "string",
            "description": "The postcode"
          },
          "isoCountry": {
            "minLength": 1,
            "pattern": "^[A-Za-z]{2}$",
            "type": "string",
            "description": "The country, ISO 3166-1 alpha-2 (GB)"
          }
        },
        "additionalProperties": false,
        "description": "A postal address"
      },
      "MessagingNumberApplicationDetailsDto": {
        "required": [
          "address",
          "businessName",
          "registrationAuthority",
          "registrationNumber",
          "representative",
          "website"
        ],
        "type": "object",
        "properties": {
          "businessName": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The registered business name"
          },
          "registrationAuthority": {
            "$ref": "#/components/schemas/MessagingRegistrationAuthority"
          },
          "registrationNumber": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The registration number: a company number for Companies House, else a UTR or VAT number"
          },
          "website": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "The public website, or a verified social media page",
            "format": "uri"
          },
          "address": {
            "$ref": "#/components/schemas/MessagingNumberApplicationAddressDto"
          },
          "representative": {
            "$ref": "#/components/schemas/MessagingNumberApplicationRepresentativeDto"
          },
          "requestedPhoneNumber": {
            "maxLength": 30,
            "minLength": 0,
            "type": "string",
            "description": "The number chosen from the available numbers, E.164; null for the first available. A chosen number taken\nbefore approval is replaced by the next available.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a practice gives to get its own number: the business, its address, the person answering for it, and the\nnumber it chose"
      },
      "MessagingNumberApplicationDto": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/MessagingNumberApplicationStatus"
          },
          "details": {
            "$ref": "#/components/schemas/MessagingNumberApplicationDetailsDto"
          },
          "addressHint": {
            "type": "string",
            "description": "The practice's address as one block of text, to copy from; null when there is none or the details are an\napplication's own",
            "nullable": true
          },
          "submittedDate": {
            "type": "string",
            "description": "When it was submitted to the review; null until then",
            "format": "date-time",
            "nullable": true
          },
          "reviewedDate": {
            "type": "string",
            "description": "When the review approved or rejected it; null until then",
            "format": "date-time",
            "nullable": true
          },
          "rejectionReasons": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Why it was turned down, in the reviewer's words; empty unless rejected",
            "nullable": true
          },
          "fieldErrors": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The reviewer's objections by field (representative.email); empty unless known",
            "nullable": true
          },
          "phoneNumber": {
            "type": "string",
            "description": "The number bought, E.164; null until then",
            "nullable": true
          },
          "appliedByUserName": {
            "type": "string",
            "description": "Who applied; null when nobody has",
            "nullable": true
          },
          "appliedDate": {
            "type": "string",
            "description": "When they applied; null when nobody has",
            "format": "date-time",
            "nullable": true
          },
          "reusable": {
            "$ref": "#/components/schemas/MessagingReusableNumberApplicationDto"
          }
        },
        "additionalProperties": false,
        "description": "The practice's application for its own UK mobile number: the Messaging Service's application when there is\none, else the form's prefill from the practice record (status null)."
      },
      "MessagingNumberApplicationRepresentativeDto": {
        "required": [
          "email",
          "firstName",
          "lastName",
          "phoneNumber"
        ],
        "type": "object",
        "properties": {
          "firstName": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "First name"
          },
          "lastName": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "Last name"
          },
          "email": {
            "maxLength": 255,
            "minLength": 0,
            "type": "string",
            "description": "A work email address; the provider expects its domain to match the business or its website",
            "format": "email"
          },
          "phoneNumber": {
            "maxLength": 30,
            "minLength": 0,
            "type": "string",
            "description": "A mobile this person answers, E.164 (+447700900123) or UK national (07700 900123); not a messaging number"
          }
        },
        "additionalProperties": false,
        "description": "The person answering for the business to the messaging provider"
      },
      "MessagingNumberApplicationStatus": {
        "enum": [
          "Draft",
          "Submitted",
          "InReview",
          "Approved",
          "Rejected",
          "Completed",
          "Cancelled",
          "Withdrawn"
        ],
        "type": "string",
        "example": "Draft"
      },
      "MessagingQuietHoursDto": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Whether automatic texts wait during the window"
          },
          "start": {
            "type": "string",
            "description": "When the window starts (inside it from this minute)",
            "format": "time"
          },
          "end": {
            "type": "string",
            "description": "When the window ends (texts held overnight go at this minute). Earlier than the start for a window that crosses\nmidnight.",
            "format": "time"
          }
        },
        "additionalProperties": false,
        "description": "The practice's quiet hours for automatic texts, on the practice's clock (UK time)"
      },
      "MessagingRecipientDto": {
        "type": "object",
        "properties": {
          "address": {
            "type": "string",
            "description": "The number: E.164 when it has a conversation, otherwise as the record holds it (the client send\nroute takes either)",
            "nullable": true
          },
          "label": {
            "type": "string",
            "description": "Which of the holder's numbers it is: Mobile, Phone or Other; null for a number on no record",
            "nullable": true
          },
          "holder": {
            "$ref": "#/components/schemas/MessagingRecipientHolderDto"
          },
          "conversationCode": {
            "type": "string",
            "description": "The code of its conversation matched to the client or one of its contacts; null when there is none\n(send on the client route with `to`)",
            "nullable": true
          },
          "whatsAppWindowClosesAt": {
            "type": "string",
            "description": "When WhatsApp free text to the number stops being allowed, as the Messaging Service stated it (24 hours after\nits newest inbound WhatsApp message); null when closed, never opened or unknown. A hint: the service decides.",
            "format": "date-time",
            "nullable": true
          },
          "lastMessageDate": {
            "type": "string",
            "description": "When its conversation's newest message arrived or was sent; null with no conversation",
            "format": "date-time",
            "nullable": true
          },
          "isKnownOnWhatsApp": {
            "type": "boolean",
            "description": "The number is known on WhatsApp to the practice (it has messaged the practice on WhatsApp, or a WhatsApp message\nto it was delivered or read): the composer shows the WhatsApp icon beside it. False with no conversation."
          },
          "optedOutChannels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessageChannel"
            },
            "description": "The channels the number has opted out of the practice's messages on (empty for none), read from\nthe Messaging Service on each call; null when the service could not be read (the send's 409 still\ndecides)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A number the client record's composer can send to: one of the client's own numbers or one of its\ncontacts', or a conversation matched to them by hand whose number is on no record. One per number,\nhowever it was typed."
      },
      "MessagingRecipientHolderDto": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/MessagingMatchCandidateType"
          },
          "code": {
            "type": "string",
            "description": "The client's or contact's code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The client's or contact's name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The client or contact holding a recipient's number"
      },
      "MessagingRegistrationAuthority": {
        "enum": [
          "CompaniesHouse",
          "Other"
        ],
        "type": "string",
        "example": "CompaniesHouse"
      },
      "MessagingRequestTemplateDto": {
        "type": "object",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/ClientRequestTextKind"
          },
          "templateId": {
            "type": "string",
            "description": "The kind's template id for this practice (the same every time), whether or not the template exists yet: the id the\ntemplate routes (PUT, DELETE …/whatsapp-templates/{id}) take",
            "format": "uuid"
          },
          "template": {
            "$ref": "#/components/schemas/MessagingWhatsAppTemplateDto"
          },
          "needsSetUp": {
            "type": "boolean",
            "description": "Whether \"Set up WhatsApp templates\" would do something for this kind: the template is missing, or Meta disabled\nit and no change is waiting"
          }
        },
        "additionalProperties": false,
        "description": "One kind of request text's standard WhatsApp template, as Request settings shows it beside the kind's SMS wording"
      },
      "MessagingRequestTextRouting": {
        "enum": [
          "SmsOnly",
          "KnownNumbers",
          "TryWhatsAppFirst"
        ],
        "type": "string",
        "example": "SmsOnly"
      },
      "MessagingRequestTextRoutingDto": {
        "type": "object",
        "properties": {
          "routing": {
            "$ref": "#/components/schemas/MessagingRequestTextRouting"
          }
        },
        "additionalProperties": false,
        "description": "How the practice's request texts choose between WhatsApp and SMS"
      },
      "MessagingReusableNumberApplicationDto": {
        "type": "object",
        "properties": {
          "applicationId": {
            "type": "integer",
            "description": "The application, for the reuse request",
            "format": "int32"
          },
          "details": {
            "$ref": "#/components/schemas/MessagingNumberApplicationDetailsDto"
          },
          "reviewedDate": {
            "type": "string",
            "description": "When the provider approved them; null when the application was withdrawn before its answer",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An earlier application, cancelled or withdrawn, whose details the provider still has approved"
      },
      "MessagingTemplateDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The template's code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "What staff pick it by; unique in the practice",
            "nullable": true
          },
          "body": {
            "type": "string",
            "description": "The text with its Liquid tokens, unrendered",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A practice's own text template for any channel: SMS, or WhatsApp within the 24-hour window. Its body uses the email\ntemplates' Liquid tokens ({{ Client.Name }}, {{ Contact.FirstName }}, {{ Practice.Name }}, {{ Url }} for\nthe client portal …) and is rendered on the server for the recipient when it is sent."
      },
      "MessagingTemplateDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessagingTemplateDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "MessagingTemplateRenderDto": {
        "type": "object",
        "properties": {
          "body": {
            "type": "string",
            "description": "The rendered text",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A practice text template rendered for one recipient, as it would be sent now"
      },
      "MessagingTemplateSortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "MessagingTextWordingsDto": {
        "type": "object",
        "properties": {
          "documentRequest": {
            "type": "string",
            "description": "For a document request",
            "nullable": true
          },
          "documentApproval": {
            "type": "string",
            "description": "For documents to approve",
            "nullable": true
          },
          "clientConfirmation": {
            "type": "string",
            "description": "For something to confirm: a client confirmation, or a CIS return",
            "nullable": true
          },
          "dataForm": {
            "type": "string",
            "description": "For a form",
            "nullable": true
          },
          "cisPayments": {
            "type": "string",
            "description": "For the CIS payments page",
            "nullable": true
          },
          "chase": {
            "type": "string",
            "description": "For the chase's text, when the practice texts its chases: {{ Url }} is the practice's portal address and\n{{ Outstanding }} what the recipient has outstanding (\"3 things\")",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The practice's wording for the text a client send step adds to its email when the step asks for one, one per kind of\nrequest. Liquid, as the practice's text templates are: {{ Url }} is the recipient's own link (the one their email\ncarries), and the client, contact, practice and task tokens are filled for them."
      },
      "MessagingWhatsAppEmbeddedSignupDto": {
        "type": "object",
        "properties": {
          "metaAppId": {
            "type": "string",
            "description": "The Meta app's ID (FB.init's appId)",
            "nullable": true
          },
          "embeddedSignupConfigId": {
            "type": "string",
            "description": "The Facebook Login for Business configuration (FB.login's config_id)",
            "nullable": true
          },
          "partnerSolutionId": {
            "type": "string",
            "description": "Twilio's Partner Solution ID (extras.setup.solutionID)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Sodium's values for opening Meta's WhatsApp Embedded Signup: public, the same for every practice"
      },
      "MessagingWhatsAppStatus": {
        "enum": [
          "Connecting",
          "Online",
          "Failed",
          "Disconnected"
        ],
        "type": "string",
        "example": "Connecting"
      },
      "MessagingWhatsAppTemplateButtonDto": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "What the button says, 1 to 20 characters",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "The address it opens: an absolute https address with at most one placeholder, at its very end",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A WhatsApp template's link button: the title the recipient taps and the address it opens, which may end with one\nplaceholder filled per recipient (https://acme.sodiumportal.com/document-request/{{2}})"
      },
      "MessagingWhatsAppTemplateCategory": {
        "enum": [
          "Utility",
          "Marketing"
        ],
        "type": "string",
        "example": "Utility"
      },
      "MessagingWhatsAppTemplateDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The template's stable id: what a send (`whatsAppTemplateId`) and a Send Text Message step name",
            "format": "uuid"
          },
          "friendlyName": {
            "type": "string",
            "description": "Its name, unique among the practice's templates",
            "nullable": true
          },
          "live": {
            "$ref": "#/components/schemas/MessagingWhatsAppTemplateVersionDto"
          },
          "pending": {
            "$ref": "#/components/schemas/MessagingWhatsAppTemplateVersionDto"
          },
          "usedBy": {
            "$ref": "#/components/schemas/MessagingWhatsAppTemplateUseDto"
          },
          "requestKind": {
            "$ref": "#/components/schemas/ClientRequestTextKind"
          }
        },
        "additionalProperties": false,
        "description": "A WhatsApp template the practice can send: one lasting template with a stable id, the live version that is sent and\na pending version (a change in Meta's review, or one Meta rejected). An edit never touches the live version: it keeps\nbeing sent until Meta approves the change, which then takes its place."
      },
      "MessagingWhatsAppTemplateRequest": {
        "type": "object",
        "properties": {
          "friendlyName": {
            "type": "string",
            "description": "Its name, 1 to 100 characters",
            "nullable": true
          },
          "language": {
            "type": "string",
            "description": "Its language, xx or xx_XX (en, en_GB); en_GB when absent",
            "nullable": true
          },
          "category": {
            "$ref": "#/components/schemas/MessagingWhatsAppTemplateCategory"
          },
          "body": {
            "type": "string",
            "description": "The text, with numbered placeholders, e.g. \"Hello {{1}}, we have a message for you about {{2}}.\"",
            "nullable": true
          },
          "samples": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "One example value per placeholder, keyed by its number ({\"1\": \"Jane\"}): Meta reviews the template with them",
            "nullable": true
          },
          "button": {
            "$ref": "#/components/schemas/MessagingWhatsAppTemplateButtonDto"
          },
          "placeholderTokens": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "What fills each placeholder, saved with the version this makes (placeholder number to a Liquid token, as on the\nversion). Required on a request template for every placeholder, with {{1}} still the first name, the button's\n{{2}} still {{ Url }}, and the chase still saying {{ Outstanding }}; optional otherwise.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A WhatsApp template the practice writes: to create one, or the whole draft of an edit. Meta's rules are checked before it\nis submitted: name 1–100 characters; body 1–1024 characters with placeholders {{1}}, {{2}}… numbered from 1 with no\ngaps, not at the start or end and never two with only white space between them; one non-empty sample (at most 200\ncharacters) per placeholder and none extra; language xx or xx_XX. A broken rule is a 400 with field errors\n(friendlyName, language, category, body, samples, samples.{n})."
      },
      "MessagingWhatsAppTemplateUseDto": {
        "type": "object",
        "properties": {
          "workflows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessagingWhatsAppTemplateWorkflowUseDto"
            },
            "description": "The workflows with a step on the template, by name",
            "nullable": true
          },
          "openTaskStepCount": {
            "type": "integer",
            "description": "How many task steps on the template are not yet done or skipped",
            "format": "int32"
          },
          "stepCount": {
            "type": "integer",
            "description": "Every step that sends it: the workflows' steps and the open task steps",
            "format": "int32"
          },
          "isUsed": {
            "type": "boolean",
            "description": "Whether any step sends it"
          }
        },
        "additionalProperties": false,
        "description": "The workflow steps that send a WhatsApp template: the workflows with a Send Text Message step on it, and how many\ntask steps on it are not yet done or skipped (counted, not named: a task's client may be one the reader cannot see)"
      },
      "MessagingWhatsAppTemplateVersionDto": {
        "type": "object",
        "properties": {
          "sid": {
            "type": "string",
            "description": "The version's Content SID (HX…); a sent message keeps the SID of the version it was sent with",
            "nullable": true
          },
          "language": {
            "type": "string",
            "description": "Its language, e.g. en",
            "nullable": true
          },
          "body": {
            "type": "string",
            "description": "The text with its placeholders, e.g. \"Your appointment is on {{1}}\"",
            "nullable": true
          },
          "variables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Each variable's name and the sample value Twilio holds for it",
            "nullable": true
          },
          "button": {
            "$ref": "#/components/schemas/MessagingWhatsAppTemplateButtonDto"
          },
          "placeholderTokens": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "What fills each placeholder, saved with this version: placeholder number to a Liquid token rendered per recipient\n({\"1\": \"{{ Contact.FirstName }}\", \"2\": \"{{ Url }}\"}; {{ Url }} is the recipient's link, of which a button's\nplaceholder takes the part after the button's fixed address; {{ Outstanding }} the chase's \"3 things\"). Request\nand chase texts render every entry; null when none was saved (a step's template, or one made in Twilio).",
            "nullable": true
          },
          "approvalStatus": {
            "type": "string",
            "description": "WhatsApp's approval as Twilio reports it (approved, pending, rejected, paused, unsubmitted…);\nnull when none. Only an approved template can be sent outside the 24-hour window.",
            "nullable": true
          },
          "category": {
            "type": "string",
            "description": "WhatsApp's category as Twilio reports it (UTILITY, MARKETING, AUTHENTICATION): the one it was submitted in, or the\none Meta moved it to; null when never submitted",
            "nullable": true
          },
          "approvalName": {
            "type": "string",
            "description": "The name it was submitted to Meta under (fee_reminder_3fa9c1); null when never submitted",
            "nullable": true
          },
          "rejectionReason": {
            "type": "string",
            "description": "Why Meta rejected it; null unless rejected with a reason",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When it was made (UTC)",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One version of a WhatsApp template: a Twilio Content template in the practice's own account, with Meta's review"
      },
      "MessagingWhatsAppTemplateWorkflowUseDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The workflow's code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The workflow's name",
            "nullable": true
          },
          "stepNames": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The names of its steps on the template",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A workflow with Send Text Message steps on a WhatsApp template"
      },
      "MonthDayType": {
        "enum": [
          "First",
          "Second",
          "Third",
          "Fourth",
          "Last",
          "SecondToLast"
        ],
        "type": "string",
        "example": "First"
      },
      "MonthFlags": {
        "enum": [
          "None",
          "January",
          "February",
          "March",
          "April",
          "May",
          "June",
          "July",
          "SemiAnnual",
          "August",
          "September",
          "October",
          "Quarterly",
          "November",
          "December",
          "AllMonths"
        ],
        "type": "string",
        "example": "None"
      },
      "MoveDocumentsToPortalFolderRequest": {
        "required": [
          "documentCodes"
        ],
        "type": "object",
        "properties": {
          "documentCodes": {
            "maxItems": 100,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the documents to move. Duplicates are ignored."
          },
          "portalFolderPath": {
            "maxLength": 2000,
            "type": "string",
            "description": "The destination folder path, \"/\" separated, e.g. \"Tax Returns/2026\".\nNull or empty moves the documents to the client's portal root.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Moves one or more documents to a different folder in the client portal.\nThis only changes where the documents appear to the client — the physical file is not moved."
      },
      "MoveDocumentsToPortalFolderResultDto": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentMoveResultDto"
            },
            "description": "One entry per document code submitted, in the order they were sent.",
            "nullable": true
          },
          "portalFolderPath": {
            "type": "string",
            "description": "The normalised destination folder path. Null means the portal root.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of a batch portal folder move. Documents are moved independently, so a batch\ncan contain a mix of successes and failures."
      },
      "MoveExternalFilesRequest": {
        "required": [
          "externalFileIds",
          "targetFolderId"
        ],
        "type": "object",
        "properties": {
          "externalFileIds": {
            "maxItems": 100,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The provider identifiers of the files to move."
          },
          "targetFolderId": {
            "minLength": 1,
            "type": "string",
            "description": "The provider identifier of the destination folder."
          },
          "portalFolderPath": {
            "maxLength": 2000,
            "type": "string",
            "description": "When set, the files Sodium tracks also move to this folder in the client portal.\nPass an empty string to move them to the portal root; omit entirely to leave the portal\nlocation alone. Storage and portal locations are otherwise independent.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Moves one or more files into a different folder in the practice's external storage provider.\nThis physically moves the file at the provider."
      },
      "MoveExternalFilesResultDto": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalFileMoveResultDto"
            },
            "description": "One entry per file submitted, in the order they were sent.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of a batch file move. Files are moved independently, so a batch can contain a\nmix of successes and failures."
      },
      "MoveMailboxConversationRequest": {
        "required": [
          "destinationFolderId",
          "sourceFolderId"
        ],
        "type": "object",
        "properties": {
          "sourceFolderId": {
            "type": "string",
            "description": "UniqueId of the folder the conversation is being moved out of. Only the conversation's\nmessages in this folder move, so replies filed in Sent stay where they are.",
            "format": "uuid"
          },
          "destinationFolderId": {
            "type": "string",
            "description": "UniqueId of the folder to move the messages to. It must belong to the same mailbox.",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "Request to move a conversation's messages from one folder of a mailbox to another"
      },
      "MoveMailboxMessagesResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether every message the caller could see ended up in the destination folder"
          },
          "movedCount": {
            "type": "integer",
            "description": "How many messages were moved. Ids the caller's access level hides, ids that are not in the\nmailbox and messages already in the destination are not counted.",
            "format": "int32"
          },
          "errorMessage": {
            "type": "string",
            "description": "Error message if the operation failed, in full or in part",
            "nullable": true
          },
          "reconnectRequired": {
            "type": "boolean",
            "description": "Whether the user needs to reconnect their mailbox"
          }
        },
        "additionalProperties": false,
        "description": "Response from the move-messages endpoint. Same success/failure shape as\nSodium.EmailService.Contracts.Responses.DraftOperationResponse, plus how many messages actually moved."
      },
      "MtdAdjustableSummaryDetailDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the summary belongs to, stamped by the API on the way out.",
            "nullable": true
          },
          "calculationId": {
            "type": "string",
            "description": "HMRC's identifier for the summary.",
            "nullable": true
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold a summary under this id at all."
          },
          "isAdjustable": {
            "type": "boolean",
            "description": "Whether HMRC will accept adjustments against this summary: it is valid and has not been\nadjusted, because HMRC accept adjustments once per summary. Decides whether the adjustment\nform is offered, so a screen never works it out from the summary's own fields.\n            \n⚠ On a sandbox connection a valid summary is always adjustable. HMRC's sandbox answers every\nretrieve with a canned summary marked as already adjusted, while its adjust endpoint accepts\nthe call, so the flag there says nothing about the summary in hand."
          },
          "selfEmployment": {
            "$ref": "#/components/schemas/SelfEmploymentBsas"
          },
          "ukProperty": {
            "$ref": "#/components/schemas/UkPropertyBsas"
          },
          "foreignProperty": {
            "$ref": "#/components/schemas/ForeignPropertyBsas"
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          }
        },
        "additionalProperties": false,
        "description": "One retrieved adjustable summary in full: the figures as submitted, the adjustments made to\nthem, and the adjusted result. Only one of the two payloads is populated, matching the income\nsource type."
      },
      "MtdAdjustableSummaryDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the summary belongs to, stamped by the API on the way out.",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the income source.",
            "nullable": true
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "accountingPeriodStartDate": {
            "type": "string",
            "description": "Start of the accounting period the summaries cover.",
            "format": "date",
            "nullable": true
          },
          "accountingPeriodEndDate": {
            "type": "string",
            "description": "End of the accounting period the summaries cover.",
            "format": "date",
            "nullable": true
          },
          "summaries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BsasSummaryInfo"
            },
            "description": "Every summary generated for this source and year, newest first.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An adjustable summary (BSAS) HMRC have generated for one income source — the accounting result\nof everything filed for the period, which the practice reviews and then adjusts.\n            \nAdjustments are **deltas**, not replacements, and HMRC accept them only once per summary. A\ncorrection therefore means triggering a fresh summary and adjusting that one, which is why the\nadjustable flag matters: it gates what the practice may do next."
      },
      "MtdAnnualSubmissionDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the income source.",
            "nullable": true
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "selfEmployment": {
            "$ref": "#/components/schemas/SelfEmploymentAnnualSubmission"
          },
          "ukProperty": {
            "$ref": "#/components/schemas/UkPropertyAnnualSubmission"
          },
          "foreignProperty": {
            "$ref": "#/components/schemas/ForeignPropertyAnnualSubmission"
          }
        },
        "additionalProperties": false,
        "description": "The year-end annual submission HMRC currently holds for one income source and tax year — the\nadjustments, allowances and non-financial declarations that change the tax computation.\n            \nUnlike a quarterly update this is not a filing with a deadline and there is no local draft:\nHMRC holds the authoritative values, a save replaces them in full, and this retrieve is what\nseeds the form — including values another vendor sent. Nothing held is the normal state before\nthe first year-end submission, not an error."
      },
      "MtdBroughtForwardLossDto": {
        "type": "object",
        "properties": {
          "lossId": {
            "type": "string",
            "description": "HMRC's identifier for the loss. Every later call about it is keyed by this.",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the income source the loss belongs to.",
            "nullable": true
          },
          "typeOfLoss": {
            "$ref": "#/components/schemas/HmrcLossType"
          },
          "lossAmount": {
            "type": "number",
            "description": "The amount carried forward, as a positive figure.",
            "format": "double"
          },
          "taxYearBroughtForwardFrom": {
            "type": "string",
            "description": "The tax year the loss arose in, e.g. 2023-24. That year must have ended.",
            "nullable": true
          },
          "lastModified": {
            "type": "string",
            "description": "When HMRC created or last changed the record. HMRC's own stamp.",
            "format": "date-time"
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          }
        },
        "additionalProperties": false,
        "description": "One loss brought forward from a year before Making Tax Digital (to 2025-26)."
      },
      "MtdBusinessDetailsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the income source belongs to, stamped by the API on the way out.",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the income source.",
            "nullable": true
          },
          "typeOfBusiness": {
            "type": "string",
            "description": "HMRC's income source type: self-employment, uk-property or foreign-property.",
            "nullable": true
          },
          "tradingName": {
            "type": "string",
            "description": "The trading name, where HMRC hold one.",
            "nullable": true
          },
          "commencementDate": {
            "type": "string",
            "description": "The date the business commenced trading, where HMRC hold one.",
            "format": "date",
            "nullable": true
          },
          "cessationDate": {
            "type": "string",
            "description": "The date the business ceased trading, if it has.",
            "format": "date",
            "nullable": true
          },
          "accountingPeriods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountingPeriodResponseDto"
            },
            "description": "The accounting periods HMRC hold for the business.",
            "nullable": true
          },
          "quarterlyPeriodType": {
            "type": "string",
            "description": "Standard or calendar quarterly periods, where a choice was actively made. HMRC only return\none when the client elected it, so null means standard quarters by default rather than\n\"unknown\".",
            "nullable": true
          },
          "quarterlyPeriodTypeTaxYear": {
            "type": "string",
            "description": "The tax year the quarterly period choice was made for, where held.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One MTD income source in detail, with its accounting periods and quarterly reporting choice."
      },
      "MtdBusinessYearConfigDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the income source belongs to, stamped by the API on the way out.",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the income source.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "accountingType": {
            "$ref": "#/components/schemas/HmrcAccountingType"
          },
          "lastAccountingTypeAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "supportsPeriodsOfAccount": {
            "type": "boolean",
            "description": "Whether periods of account apply to this income source at all. False for a property business,\nwhere HMRC hold no such resource.\n            \nWithout this a caller cannot tell \"does not apply\" from \"nothing declared yet\" — both arrive\nas a null Sodium.HmrcMtd.Product.Contracts.Dtos.MtdBusinessYearConfigDto.PeriodsOfAccount — and would have to re-derive the rule from the\nincome source type, which is the caller-side guessing the MTD service exists to remove."
          },
          "periodsOfAccount": {
            "$ref": "#/components/schemas/PeriodsOfAccountResponseDto"
          },
          "lastPeriodsOfAccountAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "supportsLateAccountingDateRule": {
            "type": "boolean",
            "description": "Whether the late accounting date rule applies to this income source at all. False for a\nproperty business. Distinct from Sodium.HmrcMtd.Product.Contracts.Dtos.LateAccountingDateRuleDto.IsEligible, which\nanswers a narrower question about a source the rule does apply to: whether its accounting date\nfalls in the 31 March to 4 April window that makes an election possible."
          },
          "lateAccountingDateRule": {
            "$ref": "#/components/schemas/LateAccountingDateRuleDto"
          },
          "lastLateAccountingDateRuleAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          }
        },
        "additionalProperties": false,
        "description": "The per-tax-year configuration HMRC hold for one income source: the accounting basis, the\nperiods of account, and the late accounting date rule election.\n            \nThese are separate HMRC resources fetched together because they are one screen to the practice\n— the year's setup for a business, decided before its figures mean anything. Periods of account\nand the late accounting date rule are self-employment only; for a property business they come\nback absent, which is correct rather than missing."
      },
      "MtdCgtPpdOverridesDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "overrides": {
            "$ref": "#/components/schemas/CgtPpdOverrides"
          }
        },
        "additionalProperties": false,
        "description": "The residential property disposals HMRC hold for a client and tax year from their own 'Report\nand pay Capital Gains Tax on UK property' service (the 60-day return), with the latest figures\nagainst each: HMRC's own, or an override sent from here.\n            \nThe disposals are HMRC's and cannot be added or removed here. What can be sent is an override\nof the figures on a return HMRC already hold, for the Self Assessment year."
      },
      "MtdCgtResidentialDisposalsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "disposals": {
            "$ref": "#/components/schemas/CgtResidentialDisposals"
          }
        },
        "additionalProperties": false,
        "description": "The UK residential property disposals HMRC hold for a client and tax year, as reported for Self\nAssessment.\n            \nThis is the Self Assessment reporting of those disposals, not the in-year property\npayment-on-account return a client files within 60 days of completion. A disposal can need\nboth, and reporting it here does not discharge the in-year obligation."
      },
      "MtdCharitableGivingDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "charitableGiving": {
            "$ref": "#/components/schemas/CharitableGivingReliefs"
          }
        },
        "additionalProperties": false,
        "description": "The charitable giving reliefs HMRC hold for a client and tax year: gift aid payments and gifts\nof shares, securities, land and buildings."
      },
      "MtdDirectorshipDividendDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "employmentId": {
            "type": "string",
            "description": "HMRC's identifier for the employment the directorship belongs to.",
            "nullable": true
          },
          "directorship": {
            "$ref": "#/components/schemas/DirectorshipDividend"
          }
        },
        "additionalProperties": false,
        "description": "The additional directorship and dividend information HMRC hold against one of the client's\nemployments. HMRC require this from 2025-26 where the client is a director of a close company,\nwhich is why it hangs off an employment rather than the tax year alone."
      },
      "MtdDividendsIncomeDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "dividends": {
            "$ref": "#/components/schemas/DividendsIncome"
          }
        },
        "additionalProperties": false,
        "description": "The foreign and special dividends HMRC hold for a client and tax year: dividends from foreign\ncompanies, dividends received whilst abroad, stock dividends, redeemable shares, bonus issues\nof securities and close company loans written off.\n            \nPlain UK dividends are a separate HMRC resource — see Sodium.HmrcMtd.Product.Contracts.Dtos.MtdUkDividendsDto — and the\ntwo are saved and cleared independently."
      },
      "MtdEmploymentCreatedDto": {
        "type": "object",
        "properties": {
          "employmentId": {
            "type": "string",
            "description": "HMRC's identifier for the new employment — the key every later call uses.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The employment HMRC created, with the identifier they issued for it."
      },
      "MtdEmploymentDetailDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the employment belongs to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "employmentId": {
            "type": "string",
            "description": "HMRC's identifier for the employment.",
            "nullable": true
          },
          "employment": {
            "$ref": "#/components/schemas/EmploymentDetails"
          },
          "financialDetails": {
            "$ref": "#/components/schemas/EmploymentFinancialDetails"
          },
          "lastEmploymentAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "lastFinancialDetailsAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          }
        },
        "additionalProperties": false,
        "description": "One employment in full: HMRC's record of it, the financial details held against it, and who\nlast changed either from Sodium.\n            \nWhether it is HMRC's own or was added here comes from the list, not from here — HMRC's record\ndoes not say, so repeating it would cost an extra call for something the caller already has."
      },
      "MtdEmploymentDto": {
        "type": "object",
        "properties": {
          "employmentId": {
            "type": "string",
            "description": "HMRC's identifier for the employment.",
            "nullable": true
          },
          "employerName": {
            "type": "string",
            "description": "The employer's name.",
            "nullable": true
          },
          "isHmrcHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold this employment from the employer's own submissions. HMRC-held employments\ncan only be ignored or unignored; custom ones can be amended and deleted. See the list\nremarks."
          },
          "dateIgnored": {
            "type": "string",
            "description": "When the employment was marked ignored, if it has been. An ignored employment is one HMRC\nhold but leave out of the tax calculation, because it is wrong or duplicated.",
            "format": "date-time",
            "nullable": true
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          }
        },
        "additionalProperties": false,
        "description": "One employment in the year's list."
      },
      "MtdEmploymentsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the employments belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "employments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdEmploymentDto"
            },
            "description": "Every employment for the year, HMRC-held and custom together, each flagged with which it is.\nEmpty when HMRC know of none — the normal state for a client with no employment income.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The employments HMRC know for a client and tax year, and the employment income that belongs to\nno single employment.\n            \nEmployments come from two places and what can be done to them differs entirely, which is the\nsingle most important thing this list carries. An employment HMRC hold — built from the\nemployer's own RTI submissions — cannot be edited or deleted, only <em>ignored</em>, which\ntells HMRC to leave it out of the tax calculation. A custom employment, added by the client or\ntheir agent for something HMRC do not hold, can be amended and deleted but never ignored.\nOffering the wrong action gets a refusal from HMRC, so\nSodium.HmrcMtd.Product.Contracts.Dtos.MtdEmploymentDto.IsHmrcHeld is what the UI keys its actions off."
      },
      "MtdFigureMappingDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for the mapping.",
            "nullable": true
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "name": {
            "type": "string",
            "description": "Display name for the mapping.",
            "nullable": true
          },
          "mappingJson": {
            "type": "string",
            "description": "The label→field entries, as JSON owned by the importing form.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The practice's remembered spreadsheet mapping for MTD quarterly-update imports: their own\ncategory labels against the figure fields of one income source type. The entries are JSON\nowned and interpreted by the form that does the importing — the server stores it verbatim."
      },
      "MtdFigureTargetDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "The dotted property path from the figure-input root, e.g. \"PeriodIncome.Turnover\". The value\nstored against a mapping entry — treat it as an opaque identifier, never parse it.",
            "nullable": true
          },
          "displayName": {
            "type": "string",
            "description": "The box in the practice's words.",
            "nullable": true
          },
          "group": {
            "type": "string",
            "description": "Where a picker should file it: \"Income\", \"Expenses\", or \"Alongside\" for the three UK property\nboxes HMRC accept next to consolidated expenses rather than inside them.",
            "nullable": true
          },
          "kind": {
            "$ref": "#/components/schemas/MtdFigureTargetKind"
          },
          "isConsolidated": {
            "type": "boolean",
            "description": "True for the single consolidated-expenses box, which excludes the whole breakdown."
          },
          "order": {
            "type": "integer",
            "description": "Display order within the income source type, following HMRC's own field order.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One box a nominal account's figures can be mapped into, derived from the MTD figure models\nrather than declared anywhere by hand."
      },
      "MtdFigureTargetKind": {
        "enum": [
          "Income",
          "Expense"
        ],
        "type": "string",
        "example": "Income"
      },
      "MtdForeignPropertiesDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the income source belongs to, stamped by the API on the way out.",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the foreign property income source.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2026-27.",
            "nullable": true
          },
          "isKeyedByProperty": {
            "type": "boolean",
            "description": "Whether this tax year identifies a let by its registered property rather than by country.\nFalse for 2025-26 and earlier, where Sodium.HmrcMtd.Product.Contracts.Dtos.MtdForeignPropertiesDto.Properties is always empty because HMRC\nkeep no register — not because the client has no lets."
          },
          "properties": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdForeignPropertyDto"
            },
            "description": "The properties HMRC hold for the year. Empty is an answer — a source with no properties\nregistered yet — and for a year keyed by country it is the only possible answer.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The foreign properties HMRC hold registered against one foreign property income source for a\ntax year, and the fact that decides whether the register applies at all.\n            \nA foreign property income source holds several lets, and HMRC changed how a let is named\nbetween two adjacent tax years: by country code up to 2025-26, by a registered property id from\n2026-27. The register is where that id comes from, so for 2026-27 onwards a property must exist\nbefore anything can be filed against it, and for 2025-26 there is no register at all.\n            \nSodium.HmrcMtd.Product.Contracts.Dtos.MtdForeignPropertiesDto.IsKeyedByProperty is on the response rather than re-derived by every consumer:\nthe boundary is a fact about the tax year and getting it wrong does not fail loudly — HMRC\nanswer that a field is malformed, not that it belongs to another year."
      },
      "MtdForeignPropertyCreatedDto": {
        "type": "object",
        "properties": {
          "propertyId": {
            "type": "string",
            "description": "HMRC's identifier for the new property.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What registering a foreign property returns: the identifier HMRC issued."
      },
      "MtdForeignPropertyDto": {
        "type": "object",
        "properties": {
          "propertyId": {
            "type": "string",
            "description": "HMRC's identifier for the property — what every filing for this let names it by.",
            "nullable": true
          },
          "propertyName": {
            "type": "string",
            "description": "The name the practice gave the property. Unique per country at HMRC.",
            "nullable": true
          },
          "countryCode": {
            "type": "string",
            "description": "ISO 3166-1 alpha-3 code for the country the property is in, e.g. \"FRA\".",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "When income stopped being received from the property. Always paired with an end reason.",
            "format": "date",
            "nullable": true
          },
          "endReason": {
            "$ref": "#/components/schemas/ForeignPropertyEndReason"
          },
          "submittedOn": {
            "type": "string",
            "description": "When HMRC recorded the property. HMRC's own stamp.",
            "format": "date-time",
            "nullable": true
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          }
        },
        "additionalProperties": false,
        "description": "One registered foreign property, with who registered or last changed it from Sodium."
      },
      "MtdForeignReliefsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "foreign": {
            "$ref": "#/components/schemas/ForeignReliefs"
          }
        },
        "additionalProperties": false,
        "description": "The foreign tax reliefs HMRC hold for a client and tax year."
      },
      "MtdHeldPositionDto": {
        "type": "object",
        "properties": {
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC holds any figures for the year."
          },
          "heldToDate": {
            "type": "string",
            "description": "The period end HMRC's held figures run to, when anything is held.",
            "format": "date",
            "nullable": true
          },
          "selfEmploymentFigures": {
            "$ref": "#/components/schemas/SelfEmploymentCumulativeSummary"
          },
          "ukPropertyFigures": {
            "$ref": "#/components/schemas/UkPropertyCumulativeSummary"
          },
          "foreignPropertyFigures": {
            "$ref": "#/components/schemas/ForeignPropertyCumulativeSummary"
          }
        },
        "additionalProperties": false,
        "description": "The cumulative position HMRC currently holds for one income source and tax year — whichever\nsoftware filed it. Nothing held is the normal state before the year's first submission, not\nan error."
      },
      "MtdIncomeSourceDto": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the income source, e.g. XAIS12345678910.",
            "nullable": true
          },
          "typeOfBusiness": {
            "type": "string",
            "description": "HMRC's income source type: self-employment, uk-property or foreign-property. Kept as HMRC's\nown string rather than mapped to an enum, because a type Sodium cannot file for — a\nfurnished holiday letting, or whatever HMRC add next — would collapse into \"unknown\" and\nhide a real business from the practice.",
            "nullable": true
          },
          "tradingName": {
            "type": "string",
            "description": "The trading name, where HMRC hold one.",
            "nullable": true
          },
          "isCurrent": {
            "type": "boolean",
            "description": "Whether HMRC still list this source among the client's income sources. False for a source that\nonly appears in the obligations — a ceased trade, most often — which the practice may still\nneed to see, because filed figures hang off it and they are the proof the filing happened."
          },
          "periods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdObligationPeriodDto"
            },
            "description": "This source's quarterly update obligation periods, earliest deadline first, every year HMRC\nreturned. Filter on each period's tax year for one year's deadlines.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One income source for a tax year, with its deadlines."
      },
      "MtdIncomeSourceType": {
        "enum": [
          "Unknown",
          "SelfEmployment",
          "UkProperty",
          "ForeignProperty"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "MtdIncomeSourcesDto": {
        "type": "object",
        "properties": {
          "availability": {
            "$ref": "#/components/schemas/MtdObligationsAvailability"
          },
          "agentRole": {
            "$ref": "#/components/schemas/HmrcAgentRole"
          },
          "canViewFinalDeclaration": {
            "type": "boolean",
            "description": "Whether the tax return obligation was retrievable. Only a main agent may see it — a supporting\nagent can submit quarterly updates but cannot finalise the client's tax position."
          },
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the year belongs to, stamped by the API on the way out.",
            "nullable": true
          },
          "availableTaxYears": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every tax year mentioned anywhere in this response, newest first — what a year picker offers.\nHMRC's window only; a caller holding its own filed records for a year HMRC has stopped listing\nmust still offer that year, or a filed record disappears behind a moving window.",
            "nullable": true
          },
          "unavailableParts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The parts HMRC could not be asked about — `income-sources`, `obligations` or\n`final-declaration`. One part failing leaves the rest usable rather than failing the\nread, and a named part means \"not asked\" rather than \"nothing there\";\n`final-declaration` failing is routine for a supporting agent rather than a sign of\nanything wrong.",
            "nullable": true
          },
          "incomeSources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdIncomeSourceDto"
            },
            "description": "The client's income sources with their quarterly update deadlines.",
            "nullable": true
          },
          "finalDeclaration": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdObligationPeriodDto"
            },
            "description": "The tax return deadlines, every year HMRC returned. Empty for a supporting agent — check\nSodium.HmrcMtd.Product.Contracts.Dtos.MtdIncomeSourcesDto.UnavailableParts to tell that apart from a client with no tax return obligation.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client's MTD income sources with every deadline HMRC expects of them, and their tax return\ndeadlines.\n            \nEverything a year view needs to draw itself, in one read — and <strong>deliberately not scoped\nto a tax year</strong>, because HMRC answers all of it per client. Scoping it would re-fetch\nidentical data every time the practice changed the year on screen. Each period carries the tax\nyear it is filed against, so a caller filters on a string rather than re-deriving a calendar\nrule the MTD service already applied.\n            \nThe income source list and the obligations answer different questions — the list is what the\nclient actually has, the obligations carry only the sources HMRC returned periods for — and\njoining them is where sources have gone missing before, so the MTD service does it.\n            \nEvery reason the client's position cannot be shown is resolved before HMRC is called, so the\npage explains itself rather than surfacing a bare error: not connected, not authorised and no\nNational Insurance number on file are all things the practice can act on."
      },
      "MtdInvestmentReliefsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "investment": {
            "$ref": "#/components/schemas/InvestmentReliefs"
          }
        },
        "additionalProperties": false,
        "description": "The investment reliefs HMRC hold for a client and tax year: venture capital trust, enterprise\ninvestment scheme, seed enterprise investment scheme and community investment subscriptions."
      },
      "MtdLossClaimDto": {
        "type": "object",
        "properties": {
          "claimId": {
            "type": "string",
            "description": "HMRC's identifier for the claim.",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the income source the claim is made against.",
            "nullable": true
          },
          "typeOfLoss": {
            "$ref": "#/components/schemas/HmrcLossType"
          },
          "typeOfClaim": {
            "$ref": "#/components/schemas/HmrcLossClaimType"
          },
          "taxYearClaimedFor": {
            "type": "string",
            "description": "The tax year the claim is made for, e.g. 2025-26.",
            "nullable": true
          },
          "sequence": {
            "type": "integer",
            "description": "Where the claim sits in the order HMRC apply carry-sideways claims, 1–99. Null for a claim\ntype HMRC do not sequence.",
            "format": "int32",
            "nullable": true
          },
          "lastModified": {
            "type": "string",
            "description": "When HMRC created or last changed the claim. HMRC's own stamp.",
            "format": "date-time"
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          }
        },
        "additionalProperties": false,
        "description": "One loss claim — what HMRC are being asked to do with a loss (to 2025-26)."
      },
      "MtdLossCreatedDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "HMRC's identifier for the new record.",
            "nullable": true
          },
          "hmrcCorrelationId": {
            "type": "string",
            "description": "HMRC's correlation id for the exchange — the only evidence MTD issues.",
            "nullable": true
          },
          "loss": {
            "$ref": "#/components/schemas/MtdBroughtForwardLossDto"
          },
          "claim": {
            "$ref": "#/components/schemas/MtdLossClaimDto"
          }
        },
        "additionalProperties": false,
        "description": "What creating a loss or a claim returns: the identifier HMRC issued."
      },
      "MtdLossesAndClaimsDto": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the income source the document belongs to.",
            "nullable": true
          },
          "submittedOn": {
            "type": "string",
            "description": "When HMRC recorded what they hold. HMRC's own stamp.",
            "format": "date-time",
            "nullable": true
          },
          "claims": {
            "$ref": "#/components/schemas/LossClaims"
          },
          "losses": {
            "$ref": "#/components/schemas/LossesBroughtForward"
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          }
        },
        "additionalProperties": false,
        "description": "One income source's losses and claims for a tax year from 2026-27 onwards — the whole position\nas a single document."
      },
      "MtdLossesDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the losses belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isRecordBased": {
            "type": "boolean",
            "description": "True when the year keeps losses and claims as individually identified records (up to\n2025-26), false when it keeps one document per income source (2026-27 onwards).\n            \nA screen must key on this rather than on the year string: it decides whether there is\nanything to edit row by row, whether claims can be reordered, and whether a save is a create\nor a replacement."
          },
          "broughtForwardLosses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdBroughtForwardLossDto"
            },
            "description": "The brought forward losses HMRC hold for the year. Record-based years only.\n            \nEmpty means HMRC hold none, which is an answer and not a failure — render an empty table.",
            "nullable": true
          },
          "claims": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdLossClaimDto"
            },
            "description": "The loss claims HMRC hold for the year. Record-based years only, and empty means none held.",
            "nullable": true
          },
          "document": {
            "$ref": "#/components/schemas/MtdLossesAndClaimsDto"
          }
        },
        "additionalProperties": false,
        "description": "A client's losses and loss claims for one tax year, in whichever of HMRC's two shapes that year\nuses — and the flag that says which.\n            \nHMRC split this at 2025-26/2026-27, and the split is not cosmetic. Up to 2025-26 (Individual\nLosses v6.0) a loss and a claim are each a <em>record</em> with an identifier: created once,\namended through that id, deleted, and — for carry-sideways claims — ordered against each other.\nFrom 2026-27 (v7.0) the whole position is one document per income source per year, with no\nidentifiers, no ordering endpoint, and a full replacement on every save.\n            \nBoth shapes are on one DTO rather than two endpoints because the practice asks one question —\n\"what losses does this client have for this year?\" — and the answer's shape is a property of\nthe year, not of the question. Sodium.HmrcMtd.Product.Contracts.Dtos.MtdLossesDto.IsRecordBased is what a screen keys on."
      },
      "MtdMappedFiguresDto": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "description": "HMRC's income source id the figures are for.",
            "nullable": true
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "platform": {
            "type": "string",
            "description": "The platform the figures came from.",
            "nullable": true
          },
          "periodFrom": {
            "type": "string",
            "description": "First day the books were asked about — the obligation period's own start.",
            "format": "date"
          },
          "periodTo": {
            "type": "string",
            "description": "Last day the books were asked about — the quarter end being reported.",
            "format": "date"
          },
          "electedBasis": {
            "$ref": "#/components/schemas/HmrcAccountingType"
          },
          "isConsolidated": {
            "type": "boolean",
            "description": "Whether the mapping files everything into the single consolidated-expenses box."
          },
          "selfEmploymentFigures": {
            "$ref": "#/components/schemas/SelfEmploymentFigureInputs"
          },
          "ukPropertyFigures": {
            "$ref": "#/components/schemas/UkPropertyFigures"
          },
          "mappedLines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdMappedLineDto"
            },
            "description": "Every account that landed in a box — the pull's working, shown before it is applied.",
            "nullable": true
          },
          "unmapped": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdUnmappedLineDto"
            },
            "description": "Profit-and-loss accounts with figures that the mapping says nothing about.",
            "nullable": true
          },
          "unmappable": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdUnmappableLineDto"
            },
            "description": "Figures the books report with no nominal code or account id at all.",
            "nullable": true
          },
          "ignoredNonProfitAndLossCount": {
            "type": "integer",
            "description": "How many accounts with figures were skipped because the platform does not file them on the\nprofit and loss — bank, debtors, capital. Counted rather than listed: they are never a job.",
            "format": "int32"
          },
          "idEntriesInvalidated": {
            "type": "boolean",
            "description": "True when the books have moved organisation or platform since the mapping was confirmed, so\nonly the nominal codes could be matched on."
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Anything worth reading before submitting — negative income, a stale mapping, a missing basis.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A draft set of figures read from the client's books for the cumulative period, ready for review\nin the quarterly-update form. Nothing here has been saved or sent — this is a read."
      },
      "MtdMappedLineDto": {
        "type": "object",
        "properties": {
          "nominalCode": {
            "type": "string",
            "nullable": true
          },
          "externalAccountId": {
            "type": "string",
            "nullable": true
          },
          "accountName": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "description": "The figure as the books reported it, debit-positive.",
            "format": "double"
          },
          "targetKey": {
            "type": "string",
            "description": "The box it was added to.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One account's figure as it landed in a box."
      },
      "MtdNominalMappingDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for the stored mapping. Empty on a suggestion, which is not stored.",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "description": "HMRC's income source id the mapping belongs to.",
            "nullable": true
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "platform": {
            "type": "string",
            "description": "The accounting platform the client's books are on.",
            "nullable": true
          },
          "externalOrgId": {
            "type": "string",
            "description": "The organisation the entries' account ids belong to.",
            "nullable": true
          },
          "isSuggested": {
            "type": "boolean",
            "description": "True when nothing is stored yet and this is the catalogue's suggestion. Confirming it with a\nPUT is what makes it the practice's own."
          },
          "isOrgStale": {
            "type": "boolean",
            "description": "True when the client's books have moved to a different organisation or platform since the\nmapping was confirmed. Codes still match; the stored account ids no longer mean anything, so\nthe mapping wants re-confirming against the new chart."
          },
          "isConsolidated": {
            "type": "boolean",
            "description": "Whether the mapping files everything into the single consolidated-expenses box."
          },
          "confirmedByUserCode": {
            "type": "string",
            "description": "Who last confirmed the mapping.",
            "nullable": true
          },
          "confirmedDate": {
            "type": "string",
            "description": "When the mapping was last confirmed.",
            "format": "date-time",
            "nullable": true
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdNominalMappingEntryDto"
            },
            "description": "One row per account, in the chart's own order. On a suggestion this is the whole live chart;\non a stored mapping it is what was confirmed, with each account's current type filled in\nwhere the account is still in the chart.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client's chart-of-accounts mapping for one MTD business — either the stored one or, before\nanything has been confirmed, a suggestion built from the platform's catalogue crossed with the\nclient's live chart."
      },
      "MtdNominalMappingEntryDto": {
        "type": "object",
        "properties": {
          "nominalCode": {
            "type": "string",
            "description": "The account's code in the books.",
            "nullable": true
          },
          "externalAccountId": {
            "type": "string",
            "description": "The platform's own identifier for the account, where it has one distinct from the code. Valid\nonly for the organisation the mapping was confirmed against.",
            "nullable": true
          },
          "accountName": {
            "type": "string",
            "description": "The account's name. Display only — matching never uses it.",
            "nullable": true
          },
          "accountType": {
            "type": "string",
            "description": "How the platform classifies the account, in its own wording. Populated from the live chart, so\nit is absent for an entry whose account has since left the chart.",
            "nullable": true
          },
          "targetKey": {
            "type": "string",
            "description": "The figure box this account feeds, or null for \"ignore this account\" — which is a stored\ndecision, not an omission, so the account stops being flagged as needing a box.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One nominal account's place in a quarterly update."
      },
      "MtdNominalMappingStatusDto": {
        "type": "object",
        "properties": {
          "isLinked": {
            "type": "boolean",
            "description": "Whether the client's record is bound to an organisation in their accounting software."
          },
          "platform": {
            "type": "string",
            "description": "The platform their books are on, when linked.",
            "nullable": true
          },
          "supportsMtdFigures": {
            "type": "boolean",
            "description": "Whether the books pull has been rolled out to that platform yet."
          },
          "mappings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdNominalMappingSummaryDto"
            },
            "description": "The mappings the client has, one per MTD business. Empty when none are set up.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Whether one client's books can feed their figures — the per-business badges on the MTD panel, in one call."
      },
      "MtdNominalMappingSummaryDto": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "nullable": true
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "confirmedByUserCode": {
            "type": "string",
            "nullable": true
          },
          "confirmedDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "isOrgStale": {
            "type": "boolean",
            "description": "True when the books have moved since the mapping was confirmed — it wants re-confirming."
          }
        },
        "additionalProperties": false,
        "description": "A stored mapping in the one line the MTD panel's badge needs."
      },
      "MtdNonPayeEmploymentDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "nonPaye": {
            "$ref": "#/components/schemas/NonPayeEmploymentIncome"
          }
        },
        "additionalProperties": false,
        "description": "The non-PAYE employment income HMRC hold for a client and tax year — tips received outside\nPAYE."
      },
      "MtdObligationPeriodDto": {
        "type": "object",
        "properties": {
          "periodStartDate": {
            "type": "string",
            "description": "Start of the period being reported on.",
            "format": "date"
          },
          "periodEndDate": {
            "type": "string",
            "description": "End of the period being reported on.",
            "format": "date"
          },
          "dueDate": {
            "type": "string",
            "description": "When the submission for this period is due.",
            "format": "date"
          },
          "isFulfilled": {
            "type": "boolean",
            "description": "Whether HMRC still expects a submission for this period."
          },
          "receivedDate": {
            "type": "string",
            "description": "When HMRC received the submission, once fulfilled.",
            "format": "date",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year this period is filed against, in HMRC's format.\n            \nWorked out by the MTD service rather than left to a caller, because the rule is not obvious\nand both plausible answers look right: a quarterly period belongs to the year its start date\nfalls in from <strong>1 April</strong> — a calendar-quarter election starts the year five days\nbefore the tax year proper — while a tax return period uses the ordinary 6 April boundary.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single obligation period and its deadline."
      },
      "MtdObligationsAvailability": {
        "enum": [
          "Available",
          "NotConnected",
          "NotAuthorised",
          "MissingClientDetails"
        ],
        "type": "string",
        "description": "Why a client's MTD obligations can or cannot be shown. Each value is a distinct thing the user\ncan act on, so the page explains the gap rather than showing an empty list or an HMRC error.",
        "example": "Available"
      },
      "MtdOtherCapitalGainsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "otherGains": {
            "$ref": "#/components/schemas/OtherCapitalGains"
          }
        },
        "additionalProperties": false,
        "description": "The capital gains HMRC hold for a client and tax year other than UK residential property:\nlisted and unlisted shares, crypto-assets, other assets and non-UK residential property, plus\nthe year's loss claims, adjustments and the relief lifetime allowances used.\n            \nUK residential property is a separate HMRC resource — see\nSodium.HmrcMtd.Product.Contracts.Dtos.MtdCgtResidentialDisposalsDto — and the two are saved and cleared independently."
      },
      "MtdOtherEmploymentIncomeDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "otherIncome": {
            "$ref": "#/components/schemas/OtherEmploymentIncome"
          }
        },
        "additionalProperties": false,
        "description": "The other employment income HMRC hold for a client and tax year: share options, shares awarded\nor received, lump sums, and the disability and foreign service deductions."
      },
      "MtdOtherIncomeDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the year belongs to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "unavailableAreas": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The areas HMRC could not be asked about, named as `dividends`, `savings`,\n`employments`, `reliefs` or `gains`.\n            \nOne area failing does not fail the read. Fourteen calls is enough that a rate limit or a\nmomentary outage on one of them is a normal event, and \"four areas reported, reliefs could not\nbe checked\" serves a practice far better than an error where a panel should be.\n            \n<strong>A named area's values mean nothing.</strong> Showing \"nothing reported\" for it would\nbe a claim about the client's tax position that nobody made — the UI must show no verdict.",
            "nullable": true
          },
          "ukDividends": {
            "$ref": "#/components/schemas/MtdUkDividendsDto"
          },
          "foreignDividends": {
            "$ref": "#/components/schemas/MtdDividendsIncomeDto"
          },
          "savingsAccounts": {
            "$ref": "#/components/schemas/MtdSavingsAccountsDto"
          },
          "otherSavings": {
            "$ref": "#/components/schemas/MtdOtherSavingsDto"
          },
          "employments": {
            "$ref": "#/components/schemas/MtdEmploymentsDto"
          },
          "nonPayeEmployment": {
            "$ref": "#/components/schemas/MtdNonPayeEmploymentDto"
          },
          "otherEmploymentIncome": {
            "$ref": "#/components/schemas/MtdOtherEmploymentIncomeDto"
          },
          "reliefs": {
            "$ref": "#/components/schemas/MtdReliefsDto"
          },
          "otherCapitalGains": {
            "$ref": "#/components/schemas/MtdOtherCapitalGainsDto"
          },
          "residentialDisposals": {
            "$ref": "#/components/schemas/MtdCgtResidentialDisposalsDto"
          }
        },
        "additionalProperties": false,
        "description": "Everything HMRC hold for a client's tax year outside their trading income: dividends, savings,\nemployment income, reliefs and capital gains.\n            \nOne read, not fourteen. HMRC keep these as fourteen independent resources across five APIs, and\nasking for them one at a time costs a round trip per resource all the way down the chain,\nre-resolves the client on each, re-reads the same submission stamps on each, and then has to be\npaced from the browser so HMRC's rate limiter does not refuse the burst. The MTD service does\nall of it in one exchange, because how hard HMRC may be asked is knowledge about HMRC.\n            \nValues, not flags. Summarising the five headings and opening the form to edit one of them need\nthe same reads, so a summary-only read would only put the fourteen calls back one heading at a\ntime."
      },
      "MtdOtherReliefsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "other": {
            "$ref": "#/components/schemas/OtherReliefs"
          }
        },
        "additionalProperties": false,
        "description": "The other reliefs HMRC hold for a client and tax year: non-deductible loan interest, payroll\ngiving, qualifying distributions, maintenance payments, post-cessation trade relief, annual\npayments and qualifying loan interest."
      },
      "MtdOtherSavingsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "otherSavings": {
            "$ref": "#/components/schemas/OtherSavingsIncome"
          }
        },
        "additionalProperties": false,
        "description": "The savings income HMRC hold for a client and tax year that does not belong to a named account:\ninterest from gilt-edged and other UK securities, and foreign interest."
      },
      "MtdPensionsReliefsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "pensions": {
            "$ref": "#/components/schemas/PensionsReliefs"
          }
        },
        "additionalProperties": false,
        "description": "The pension contribution reliefs HMRC hold for a client and tax year."
      },
      "MtdPeriodTypeReceiptDto": {
        "type": "object",
        "properties": {
          "hmrcCorrelationId": {
            "type": "string",
            "description": "HMRC's correlation id for the exchange.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of electing a quarterly period type with HMRC. MTD issues no receipt — the\ncorrelation id is the practice's evidence of the change."
      },
      "MtdQuarterlySubmissionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for the prepared update.",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The client the income source belongs to.",
            "nullable": true
          },
          "businessId": {
            "type": "string",
            "description": "HMRC's identifier for the income source.",
            "nullable": true
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year the cumulative figures run from, e.g. 2025-26.",
            "nullable": true
          },
          "periodStartDate": {
            "type": "string",
            "description": "Start of the period covered — the start of the tax year.",
            "format": "date"
          },
          "periodEndDate": {
            "type": "string",
            "description": "End of the period covered — the quarter end being reported.",
            "format": "date"
          },
          "status": {
            "$ref": "#/components/schemas/MtdSubmissionStatus"
          },
          "selfEmploymentFigures": {
            "$ref": "#/components/schemas/SelfEmploymentCumulativeSummary"
          },
          "ukPropertyFigures": {
            "$ref": "#/components/schemas/UkPropertyCumulativeSummary"
          },
          "foreignPropertyFigures": {
            "$ref": "#/components/schemas/ForeignPropertyCumulativeSummary"
          },
          "preparedByUserCode": {
            "type": "string",
            "description": "The user who last saved the figures.",
            "nullable": true
          },
          "submittedByUserCode": {
            "type": "string",
            "description": "The user who submitted to HMRC.",
            "nullable": true
          },
          "submittedDate": {
            "type": "string",
            "description": "When the figures were sent to HMRC.",
            "format": "date-time",
            "nullable": true
          },
          "isDeclarationConfirmed": {
            "type": "boolean",
            "description": "Whether the submitter confirmed the figures were correct."
          },
          "hmrcCorrelationId": {
            "type": "string",
            "description": "HMRC's correlation id for the submission. MTD has no receipt — quote this to HMRC when\nquerying what they received.",
            "nullable": true
          },
          "failureReason": {
            "type": "string",
            "description": "Why HMRC rejected the submission, when it did.",
            "nullable": true
          },
          "calculationId": {
            "type": "string",
            "description": "The tax calculation triggered after submission, if any.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the update was first prepared.",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the update was last changed.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An MTD Income Tax quarterly update the practice has prepared or sent for one income source.\nFigures are cumulative from the start of the tax year."
      },
      "MtdReliefsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the reliefs belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "investment": {
            "$ref": "#/components/schemas/MtdInvestmentReliefsDto"
          },
          "other": {
            "$ref": "#/components/schemas/MtdOtherReliefsDto"
          },
          "foreign": {
            "$ref": "#/components/schemas/MtdForeignReliefsDto"
          },
          "pensions": {
            "$ref": "#/components/schemas/MtdPensionsReliefsDto"
          },
          "charitableGiving": {
            "$ref": "#/components/schemas/MtdCharitableGivingDto"
          }
        },
        "additionalProperties": false,
        "description": "Every relief HMRC hold for a client and tax year, in one read.\n            \nHMRC split reliefs across five independent resources and each is saved and cleared on its own.\nThey are fetched together here because a practice reviews the client's reliefs as one job — and\nbecause five separate round trips from the browser would show the five halves of one answer\narriving out of step."
      },
      "MtdSavingsAccountCreatedDto": {
        "type": "object",
        "properties": {
          "savingsAccountId": {
            "type": "string",
            "description": "HMRC's identifier for the new account — the key every later call uses.",
            "nullable": true
          },
          "accountName": {
            "type": "string",
            "description": "The account's display name, as HMRC recorded it.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The account HMRC created, with the identifier they issued for it."
      },
      "MtdSavingsAccountDto": {
        "type": "object",
        "properties": {
          "savingsAccountId": {
            "type": "string",
            "description": "HMRC's identifier for the account.",
            "nullable": true
          },
          "accountName": {
            "type": "string",
            "description": "The account's display name, as HMRC hold it. Unique per client at HMRC.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold interest for this account in this tax year."
          },
          "interest": {
            "$ref": "#/components/schemas/SavingsAccountInterest"
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          }
        },
        "additionalProperties": false,
        "description": "One UK savings account, with whatever interest HMRC hold against it for the year."
      },
      "MtdSavingsAccountsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the accounts belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year the interest figures below belong to, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdSavingsAccountDto"
            },
            "description": "Every account HMRC hold for the client, whichever software registered it. Empty when the\nclient has none — the normal state, not an error.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The client's UK savings accounts and the interest reported against each for one tax year.\n            \nThe two halves have different lifetimes at HMRC and it matters: an account is registered once\nand lives across every year, while its interest belongs to a single year. So an account that\nappears here with no interest is a normal, fully-registered account that simply has nothing\nreported for the year selected — not a broken or half-created record."
      },
      "MtdStudentLoanBenefitDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "employmentId": {
            "type": "string",
            "description": "The employment the figure belongs to.",
            "nullable": true
          },
          "benefit": {
            "$ref": "#/components/schemas/StudentLoanBenefitInKind"
          }
        },
        "additionalProperties": false,
        "description": "The payrolled benefits that affect student loan repayments, as HMRC hold them for one of a\nclient's employments (2025-26 onwards)."
      },
      "MtdSubmissionReceiptDto": {
        "type": "object",
        "properties": {
          "hmrcCorrelationId": {
            "type": "string",
            "description": "HMRC's correlation id for the exchange.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of a year-end write to HMRC — an annual submission, an adjustment, or an other-income\nresource. HMRC issues no receipt document for these, so the correlation id is the practice's\nonly evidence the exchange happened and the reference to quote to HMRC support."
      },
      "MtdSubmissionStampDto": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "description": "What kind of submission was sent.",
            "nullable": true
          },
          "action": {
            "type": "string",
            "description": "Whether values were submitted or the held submission was deleted.",
            "nullable": true
          },
          "reference": {
            "type": "string",
            "description": "The identifier scoping the submission within its kind — the income source for annual\nsubmissions, the calculation for BSAS adjustments, and so on. Null for kinds scoped by tax\nyear alone.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "performedByUserCode": {
            "type": "string",
            "description": "The code of the Sodium user who performed the action, where it was one of ours.",
            "nullable": true
          },
          "performedDate": {
            "type": "string",
            "description": "When the action happened (UTC).",
            "format": "date-time"
          },
          "hmrcCorrelationId": {
            "type": "string",
            "description": "HMRC's correlation id for the exchange, for support enquiries.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A record of one year-end submission Sodium sent to HMRC, or one it deleted. HMRC cannot answer\nwho sent what, so the MTD service stamps every write and these are those stamps."
      },
      "MtdSubmissionStatus": {
        "enum": [
          "Draft",
          "Submitting",
          "Submitted",
          "Failed",
          "Superseded"
        ],
        "type": "string",
        "description": "Lifecycle of a prepared MTD quarterly update. Draft-then-submit is deliberate: the practice can\nprepare figures, leave, and come back, and submitting is a single explicit step.",
        "example": "Draft"
      },
      "MtdTaxCalculationDto": {
        "type": "object",
        "properties": {
          "calculationId": {
            "type": "string",
            "description": "HMRC's identifier for the calculation.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year the calculation covers, e.g. 2025-26.",
            "nullable": true
          },
          "calculationTimestamp": {
            "type": "string",
            "description": "When HMRC finished calculating. Absent while the calculation is still running.",
            "format": "date-time",
            "nullable": true
          },
          "periodTo": {
            "type": "string",
            "description": "The latest date the calculation covers — how far HMRC's information about the client's income\nand expenses runs. This is the date HMRC's mandated accuracy disclaimer quotes, and it is\n<strong>not</strong>Sodium.HmrcMtd.Product.Contracts.Dtos.MtdTaxCalculationDto.CalculationTimestamp: that is when HMRC ran the\ncalculation, this is what the calculation is based on. Absent while the calculation is still\nrunning, or where HMRC did not state a period.",
            "format": "date",
            "nullable": true
          },
          "isComplete": {
            "type": "boolean",
            "description": "True once HMRC has finished and produced totals."
          },
          "hasErrors": {
            "type": "boolean",
            "description": "True when the calculation ran but could not produce a usable result. A failed calculation is\nan answer — the messages say why — not something to keep polling for."
          },
          "estimatedIncomeTaxNicAmount": {
            "type": "number",
            "description": "HMRC's estimated income tax and NICs for the full year — the headline \"HMRC now estimates\"\nfigure shown after a quarterly update.",
            "format": "double",
            "nullable": true
          },
          "estimatedTotalIncome": {
            "type": "number",
            "description": "HMRC's estimated total income for the full year.",
            "format": "double",
            "nullable": true
          },
          "estimatedTaxableIncome": {
            "type": "number",
            "description": "HMRC's estimated taxable income for the full year.",
            "format": "double",
            "nullable": true
          },
          "totalIncomeTaxAndNicsDue": {
            "type": "number",
            "description": "Total income tax and NICs due on the position calculated so far.",
            "format": "double",
            "nullable": true
          },
          "errorMessages": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Why the calculation failed, when it did.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "HMRC's tax calculation for a client's year, run after a quarterly update was accepted — the\nestimated position with the new figures in. HMRC calculates asynchronously, so an incomplete\nresult shortly after submission is normal: check again rather than treating it as a failure."
      },
      "MtdTaxLiabilityAdjustmentsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "submittedOn": {
            "type": "string",
            "description": "When HMRC last received these adjustments, from whichever software sent them.",
            "format": "date-time",
            "nullable": true
          },
          "carryBackLossesDecrease": {
            "$ref": "#/components/schemas/CarryBackLossesDecrease"
          },
          "taxRefundedOrSetOff": {
            "type": "number",
            "description": "Tax already refunded or set off for the year, as a positive figure.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The tax liability adjustments HMRC hold for a client's tax year: what a carry-back loss claim\nis worth against the year's bill, and any tax already refunded or set off.\n            \n⚠ HMRC support these from <strong>2026-27</strong> only, and there is no earlier equivalent. An\nearlier year is refused rather than answered empty, because \"nothing held\" would read as \"this\nclient made no adjustments\" when the truth is that the year has none to make."
      },
      "MtdTaxReturnCalculationDto": {
        "type": "object",
        "properties": {
          "calculationId": {
            "type": "string",
            "description": "HMRC's identifier for the calculation. HMRC work it out after answering, so the figures are\nread back through the review a few seconds later rather than returned here.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What triggering a tax return calculation returns: the calculation HMRC started."
      },
      "MtdTaxReturnDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client the year belongs to.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "review": {
            "$ref": "#/components/schemas/TaxYearReturnResponse"
          },
          "agentRole": {
            "$ref": "#/components/schemas/HmrcAgentRole"
          },
          "canFile": {
            "type": "boolean",
            "description": "Whether this practice may send the return at all.\n            \nFalse for a supporting agent: HMRC allow them a client's quarterly updates and refuse them\nthe tax return, so a screen offering Submit would be offering something HMRC will reject.\nThe review reflects the same refusal from HMRC's side — the tax return obligation lands on\n`unavailableParts` — but this answers it from the capacity we recorded, which is known\nbefore HMRC is asked."
          },
          "creditCost": {
            "type": "integer",
            "description": "How many filing credits sending this return will cost, from the platform cost registry.\n            \nShown before the declaration is agreed, not after: a practice about to spend a credit should\nknow it. Null when the cost registry holds no row for a tax return, which is not \"free\" —\nthe registry fails closed and the filing would be refused.",
            "format": "int32",
            "nullable": true
          },
          "creditsAvailable": {
            "type": "integer",
            "description": "The credits the practice has left. Null when this tenant is not on a credit plan.",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Everything a practice has to look at before sending a client's tax return: every income\nsource's obligations, reporting setup, held position and year-end work; all the other income;\nthe losses; the liability adjustments where the year has them; HMRC's calculation; and the\ndeclaration with whatever is standing in the way.\n            \nOne read, because HMRC's precondition for the return is that the customer \"has already provided\ntheir entire income\" — assembled from the granular endpoints that is thirty or more HMRC\nrequests driven from a browser.\n            \n⚠ Sodium.HmrcMtd.Product.Contracts.Dtos.MtdTaxReturnDto.Review carries the MTD service's own answer rather than a restatement of it.\nEvery other MTD read here maps into per-area shapes because a form binds them; this one is read\nonly, and re-declaring two hundred properties a screen displays and never edits would be\nrestatement that drifts. What this DTO adds is what the MTD service cannot know: whether this\npractice may file at all, and what it will cost."
      },
      "MtdTaxReturnSubmissionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The submission's code, issued by the MTD service.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year declared.",
            "nullable": true
          },
          "calculationId": {
            "type": "string",
            "description": "The calculation that was declared.",
            "nullable": true
          },
          "declarationType": {
            "$ref": "#/components/schemas/HmrcFinalDeclarationType"
          },
          "status": {
            "$ref": "#/components/schemas/TaxReturnStatus"
          },
          "submittedBy": {
            "type": "string",
            "description": "The Sodium user who agreed the declaration and sent it.",
            "nullable": true
          },
          "submittedDate": {
            "type": "string",
            "description": "When it was sent to HMRC.",
            "format": "date-time",
            "nullable": true
          },
          "declarationVersion": {
            "type": "string",
            "description": "Which version of HMRC's declaration wording was agreed to.",
            "nullable": true
          },
          "hmrcCorrelationId": {
            "type": "string",
            "description": "HMRC's correlation id for the exchange. MTD issues no filing receipt, so this — with the\naudit row holding the raw exchange — is the whole of the evidence that a return was sent.",
            "nullable": true
          },
          "failureReason": {
            "type": "string",
            "description": "Why HMRC refused it, when the status is Failed.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A tax return sent to HMRC from Sodium, for the filing history on a client's year.\n            \n⚠ A submission left Sodium.HmrcMtd.Contracts.Enums.TaxReturnStatus.Submitting is <strong>not</strong> a failure\nand must never be offered a second send. HMRC create something that cannot be re-stated, so an\nunknown outcome is settled by reconciling it against HMRC's own record — never by sending\nagain."
      },
      "MtdTriggeredSummaryDto": {
        "type": "object",
        "properties": {
          "calculationId": {
            "type": "string",
            "description": "HMRC's identifier for the newly generated summary.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of asking HMRC for a new adjustable summary. The identifier is what the practice\nretrieves and adjusts against."
      },
      "MtdUkDividendsDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The Sodium client the values belong to, stamped by the API on the way out.",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26.",
            "nullable": true
          },
          "isHeld": {
            "type": "boolean",
            "description": "Whether HMRC hold anything for this resource and tax year."
          },
          "lastAction": {
            "$ref": "#/components/schemas/MtdSubmissionStampDto"
          },
          "ukDividends": {
            "$ref": "#/components/schemas/UkDividendsIncome"
          }
        },
        "additionalProperties": false,
        "description": "The plain UK dividends HMRC hold for a client and tax year — dividends from UK companies and\nother UK sources such as authorised unit trusts. The pair is saved and cleared together."
      },
      "MtdUnmappableLineDto": {
        "type": "object",
        "properties": {
          "accountName": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "format": "double"
          },
          "reason": {
            "type": "string",
            "description": "Why it cannot be mapped, in words the practice can act on.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A figure that can never be mapped, because the books report it with no key at all."
      },
      "MtdUnmappedLineDto": {
        "type": "object",
        "properties": {
          "nominalCode": {
            "type": "string",
            "nullable": true
          },
          "externalAccountId": {
            "type": "string",
            "nullable": true
          },
          "accountName": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "format": "double"
          },
          "chartType": {
            "type": "string",
            "description": "How the platform classifies the account, in its own wording.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An account with figures that the mapping says nothing about — the \"needs a box\" list."
      },
      "MtdVerificationItemDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code.",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name.",
            "nullable": true
          },
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          },
          "status": {
            "$ref": "#/components/schemas/AgentAuthorisationStatus"
          },
          "hmrcAgentRole": {
            "$ref": "#/components/schemas/HmrcAgentRole"
          },
          "verificationResult": {
            "$ref": "#/components/schemas/HmrcVerificationResult"
          },
          "lastVerifiedDate": {
            "type": "string",
            "description": "When the authorisation was last checked with HMRC.",
            "format": "date-time",
            "nullable": true
          },
          "canVerify": {
            "type": "boolean",
            "description": "Whether enough is known about the client to ask HMRC. False means the client is missing an\nNI number or VAT number, or the known fact that proves it."
          }
        },
        "additionalProperties": false,
        "description": "One client's MTD authorisation and what HMRC has confirmed about it."
      },
      "MtdVerificationSweepResultDto": {
        "type": "object",
        "properties": {
          "queuedCount": {
            "type": "integer",
            "description": "How many authorisations were queued for checking. Authorisations whose client is missing an\nidentifier or known fact are not queued and are not counted here.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The outcome of starting a practice-wide verification sweep."
      },
      "MyOtherEmailAddressesDto": {
        "type": "object",
        "properties": {
          "addresses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OtherEmailAddressDto"
            },
            "description": "Their other addresses, in the order they were added",
            "nullable": true
          },
          "suggestions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SuggestedEmailAddressDto"
            },
            "description": "Accounts the practice's note takers are connected with that belong to no one in the practice and may be theirs,\nfor them to add or ignore",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The signed-in team member's other email addresses (#2895), with the ones Sodium thinks may also be theirs.\nOther addresses are used only to recognise them as staff in meeting notes and email: nothing is sent to them and\nnobody signs in with them."
      },
      "NameTokenDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Literal token text to write between the braces, e.g. \"ClientName\" or \"Month.Previous.Name\".\nCase-sensitive.",
            "nullable": true
          },
          "group": {
            "type": "string",
            "description": "Group heading the token is listed under, e.g. \"Month\".",
            "nullable": true
          },
          "displayName": {
            "type": "string",
            "description": "Plain-English label, e.g. \"Name of last month\".",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "One-line explanation with an example value.",
            "nullable": true
          },
          "sampleValue": {
            "type": "string",
            "description": "The token resolved against today with illustrative client/service/schedule values, so the\neditors can render a live preview of a name template without re-implementing the vocabulary\nclient-side (which is how dotted tokens came to render as raw text in the preview line).",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One token offered by the recurring-task-name and document-name editors. Used to build the token\npicker, so the list is always exactly what the server can resolve."
      },
      "Nationality": {
        "enum": [
          "Afghan",
          "Albanian",
          "Algerian",
          "American",
          "Andorran",
          "Angolan",
          "Antiguan",
          "Argentine",
          "Armenian",
          "Australian",
          "Austrian",
          "Azerbaijani",
          "Bahamian",
          "Bahraini",
          "Bangladeshi",
          "Barbadian",
          "Belarusian",
          "Belgian",
          "Belizean",
          "Beninese",
          "Bhutanese",
          "Bolivian",
          "Bosnian",
          "Botswanan",
          "Brazilian",
          "British",
          "Bruneian",
          "Bulgarian",
          "Burkinabe",
          "Burmese",
          "Burundian",
          "Cambodian",
          "Cameroonian",
          "Canadian",
          "CapeVerdean",
          "CentralAfrican",
          "Chadian",
          "Chilean",
          "Chinese",
          "Colombian",
          "Comoran",
          "Congolese",
          "CostaRican",
          "Croatian",
          "Cuban",
          "Cypriot",
          "Czech",
          "Danish",
          "Djiboutian",
          "Dominican",
          "Dutch",
          "EastTimorese",
          "Ecuadorean",
          "Egyptian",
          "Emirati",
          "EquatorialGuinean",
          "Eritrean",
          "Estonian",
          "Eswatini",
          "Ethiopian",
          "Fijian",
          "Filipino",
          "Finnish",
          "French",
          "Gabonese",
          "Gambian",
          "Georgian",
          "German",
          "Ghanaian",
          "Greek",
          "Grenadian",
          "Guatemalan",
          "Guinean",
          "GuineaBissauan",
          "Guyanese",
          "Haitian",
          "Honduran",
          "Hungarian",
          "Icelandic",
          "Indian",
          "Indonesian",
          "Iranian",
          "Iraqi",
          "Irish",
          "Israeli",
          "Italian",
          "Ivorian",
          "Jamaican",
          "Japanese",
          "Jordanian",
          "Kazakh",
          "Kenyan",
          "Kiribati",
          "Kuwaiti",
          "Kyrgyz",
          "Laotian",
          "Latvian",
          "Lebanese",
          "Liberian",
          "Libyan",
          "Liechtenstein",
          "Lithuanian",
          "Luxembourgish",
          "Macedonian",
          "Malagasy",
          "Malawian",
          "Malaysian",
          "Maldivian",
          "Malian",
          "Maltese",
          "Marshallese",
          "Mauritanian",
          "Mauritian",
          "Mexican",
          "Micronesian",
          "Moldovan",
          "Monegasque",
          "Mongolian",
          "Montenegrin",
          "Moroccan",
          "Mosotho",
          "Mozambican",
          "Namibian",
          "Nauruan",
          "Nepalese",
          "NewZealander",
          "Nicaraguan",
          "Nigerian",
          "Nigerien",
          "NorthKorean",
          "Norwegian",
          "Omani",
          "Pakistani",
          "Palauan",
          "Palestinian",
          "Panamanian",
          "PapuaNewGuinean",
          "Paraguayan",
          "Peruvian",
          "Polish",
          "Portuguese",
          "Qatari",
          "Romanian",
          "Russian",
          "Rwandan",
          "SaintKittsAndNevis",
          "SaintLucian",
          "Salvadoran",
          "Samoan",
          "SanMarinese",
          "SaoTomean",
          "Saudi",
          "Senegalese",
          "Serbian",
          "Seychellois",
          "SierraLeonean",
          "Singaporean",
          "Slovak",
          "Slovenian",
          "SolomonIslander",
          "Somali",
          "SouthAfrican",
          "SouthKorean",
          "SouthSudanese",
          "Spanish",
          "SriLankan",
          "Sudanese",
          "Surinamese",
          "Swedish",
          "Swiss",
          "Syrian",
          "Taiwanese",
          "Tajik",
          "Tanzanian",
          "Thai",
          "Togolese",
          "Tongan",
          "Trinidadian",
          "Tunisian",
          "Turkish",
          "Turkmen",
          "Tuvaluan",
          "Ugandan",
          "Ukrainian",
          "Uruguayan",
          "Uzbek",
          "Vanuatuan",
          "Vatican",
          "Venezuelan",
          "Vietnamese",
          "Vincentian",
          "Yemeni",
          "Zambian",
          "Zimbabwean"
        ],
        "type": "string",
        "example": "Afghan"
      },
      "NewMailAlertScope": {
        "enum": [
          "All",
          "MineOrUnassigned"
        ],
        "type": "string",
        "example": "All"
      },
      "NextStepDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The step's name",
            "nullable": true
          },
          "assignedUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "isAutoExecute": {
            "type": "boolean",
            "description": "Whether the step will be executed automatically by the system rather than a person"
          }
        },
        "additionalProperties": false,
        "description": "A workflow step on a task that is executable right now: not omitted, not complete, and\nwith all its dependencies satisfied. A task can have several in parallel."
      },
      "NominalCodeDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The nominal code as the books hold it. Platforms that let an account go without one fall\nback to their internal identifier, so this is always populated but not always numeric.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The account's name in the books.",
            "nullable": true
          },
          "type": {
            "type": "string",
            "description": "How the platform classifies the account — its own wording (Xero \"REVENUE\", Sage \"Sales\"),\ndeliberately not normalised, because every platform charts differently.",
            "nullable": true
          },
          "externalAccountId": {
            "type": "string",
            "description": "The platform's own identifier for the account, where it has one distinct from the code.\nStable across a re-coding in the books, so it is what a stored mapping keys on; null where the\nplatform's only identifier is the code itself.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One account in a chart of accounts, as the connected accounting platform holds it.\n            \nShared by the practice's own books and a client's — the managers draw no distinction between\nthe two, so neither does the wire shape."
      },
      "NominalCodeDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NominalCodeDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "NonPayeEmploymentIncome": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "source": {
            "type": "string",
            "nullable": true
          },
          "totalNonPayeIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "tips": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "NonStandardGains": {
        "type": "object",
        "properties": {
          "attributedGains": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "attributedGainsRttTaxPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherGains": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherGainsRttTaxPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "NonUkCharities": {
        "type": "object",
        "properties": {
          "charityNames": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "totalAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "NotClientEmailRuleDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this marker",
            "nullable": true
          },
          "value": {
            "type": "string",
            "description": "The lower-cased email address or domain",
            "nullable": true
          },
          "isDomain": {
            "type": "boolean",
            "description": "Whether the value is a whole domain rather than one address"
          },
          "createdDate": {
            "type": "string",
            "description": "When the marker was added",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "An email address or domain marked as not a client. Conversations whose every external participant\nmatches one show under Other rather than Unmatched."
      },
      "NotClientEmailRuleDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotClientEmailRuleDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "NotClientEmailRuleSortField": {
        "enum": [
          "Value",
          "CreatedDate"
        ],
        "type": "string",
        "example": "Value"
      },
      "NoteDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this note",
            "nullable": true
          },
          "text": {
            "type": "string",
            "description": "The note text",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "The date/time of the note",
            "format": "date-time"
          },
          "noteFromUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "pinnedLevel": {
            "type": "integer",
            "description": "The pinned level: 0 not pinned, 1 top of the notes section, 2 top of the client or task page, 3 the dashboard",
            "format": "int32"
          },
          "createdDate": {
            "type": "string",
            "description": "When the note was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the note was last updated",
            "format": "date-time",
            "nullable": true
          },
          "stepNumber": {
            "type": "integer",
            "description": "The workflow step number if this is a step-level note (null for task-level notes)",
            "format": "int32",
            "nullable": true
          },
          "groupNumber": {
            "type": "integer",
            "description": "The workflow group number if this is a step-level note (null for task-level notes)",
            "format": "int32",
            "nullable": true
          },
          "stepName": {
            "type": "string",
            "description": "The name of the workflow step if this is a step-level note (null for task-level notes)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A note attached to an entity such as a client or task"
      },
      "NoteDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NoteDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "NotificationArchivedReason": {
        "enum": [
          "User",
          "Resolved"
        ],
        "type": "string",
        "example": "User"
      },
      "NotificationChannel": {
        "enum": [
          "InApp",
          "Email",
          "Desktop",
          "Push"
        ],
        "type": "string",
        "example": "InApp"
      },
      "NotificationDevicePlatform": {
        "enum": [
          "Ios",
          "Android"
        ],
        "type": "string",
        "example": "Ios"
      },
      "NotificationDeviceRequest": {
        "type": "object",
        "properties": {
          "isSandbox": {
            "type": "boolean"
          },
          "platform": {
            "$ref": "#/components/schemas/NotificationDevicePlatform"
          }
        },
        "additionalProperties": false
      },
      "NotificationDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "data": { },
          "title": {
            "type": "string",
            "nullable": true
          },
          "body": {
            "type": "string",
            "nullable": true
          },
          "actionUrl": {
            "type": "string",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "format": "date-time"
          },
          "seenDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "readDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "markedUnreadDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "archivedDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "archivedReason": {
            "$ref": "#/components/schemas/NotificationArchivedReason"
          },
          "isRedacted": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "NotificationFeedDto": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationDto"
            },
            "nullable": true
          },
          "hasMore": {
            "type": "boolean"
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "NotificationPreferenceCategoryDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "nullable": true
          },
          "label": {
            "type": "string",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationPreferenceTypeDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "NotificationPreferenceChannelDto": {
        "type": "object",
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/NotificationChannel"
          },
          "enabled": {
            "type": "boolean"
          },
          "isChosen": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "NotificationPreferenceTypeDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "label": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "isOnByDefault": {
            "type": "boolean"
          },
          "channels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationPreferenceChannelDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "NotificationPreferenceUpdate": {
        "required": [
          "type"
        ],
        "type": "object",
        "properties": {
          "type": {
            "minLength": 1,
            "type": "string"
          },
          "channel": {
            "$ref": "#/components/schemas/NotificationChannel"
          },
          "enabled": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "NotificationPreferencesDto": {
        "type": "object",
        "properties": {
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationPreferenceCategoryDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "NotificationSummaryDto": {
        "type": "object",
        "properties": {
          "unseenCount": {
            "type": "integer",
            "format": "int32"
          },
          "unreadCount": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "NotificationView": {
        "enum": [
          "Inbox",
          "Unread",
          "Done"
        ],
        "type": "string",
        "example": "Inbox"
      },
      "NotifyClientDocumentsRequest": {
        "required": [
          "documentCodes"
        ],
        "type": "object",
        "properties": {
          "documentCodes": {
            "maxItems": 50,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the documents to notify the client about. Duplicates are ignored."
          },
          "recipientEmails": {
            "type": "string",
            "description": "Comma-separated email addresses of recipients to send the notification to",
            "nullable": true
          },
          "message": {
            "type": "string",
            "description": "Optional personal message included in the notification email via the\n{{ Message }} template token. May contain HTML and template tokens.",
            "nullable": true
          },
          "includeAttachment": {
            "type": "boolean",
            "description": "Whether to attach the document files to the notification email in addition to the view\nlinks. Limited to 15MB across all attachments."
          }
        },
        "additionalProperties": false,
        "description": "Sends the specified recipients one email covering one or more documents, each with its own\nsecure link to view it in the portal."
      },
      "NumberFormat": {
        "type": "object",
        "properties": {
          "decimalPlaces": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "thousandsSeparator": {
            "type": "boolean"
          },
          "currencySymbol": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "OAuthSettingsRequest": {
        "required": [
          "returnUrl"
        ],
        "type": "object",
        "properties": {
          "returnUrl": {
            "minLength": 1,
            "type": "string",
            "description": "URL to redirect to after OAuth flow completes (success or failure)"
          },
          "allowSend": {
            "type": "boolean",
            "description": "Whether this configuration should be able to send emails (defaults to true)"
          },
          "allowRead": {
            "type": "boolean",
            "description": "Whether this configuration should be able to read/sync mailbox emails (defaults to false)"
          }
        },
        "additionalProperties": false,
        "description": "OAuth settings for initiating OAuth flow (used with Microsoft365 or Google provider types)"
      },
      "OAuthStatusResponse": {
        "type": "object",
        "properties": {
          "isConnected": {
            "type": "boolean",
            "description": "Whether OAuth is connected"
          },
          "sendAsEmail": {
            "type": "string",
            "description": "Email address being sent as (null if not connected)",
            "nullable": true
          },
          "connectedBy": {
            "type": "string",
            "description": "Email of the user who authorized (null if not connected)",
            "nullable": true
          },
          "connectedAt": {
            "type": "string",
            "description": "When OAuth was connected (null if not connected)",
            "format": "date-time",
            "nullable": true
          },
          "canSetCategories": {
            "type": "boolean",
            "description": "Whether the connection was granted the permission to show triage statuses as Outlook categories\n(Microsoft 365: MailboxSettings.ReadWrite). False for a mailbox connected before it was asked for:\nreconnecting grants it. Always false for Google."
          },
          "authorisationUrl": {
            "type": "string",
            "description": "Authorisation URL to redirect user to for OAuth flow (only present when initiating OAuth)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response containing OAuth connection status for Microsoft365/Google providers"
      },
      "ObligationPeriod": {
        "type": "object",
        "properties": {
          "periodStartDate": {
            "type": "string",
            "format": "date"
          },
          "periodEndDate": {
            "type": "string",
            "format": "date"
          },
          "dueDate": {
            "type": "string",
            "format": "date"
          },
          "status": {
            "$ref": "#/components/schemas/HmrcObligationStatus"
          },
          "receivedDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "periodKey": {
            "type": "string",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Officer": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "officerRole": {
            "type": "string",
            "nullable": true
          },
          "appointedOn": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "resignedOn": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "nationality": {
            "type": "string",
            "nullable": true
          },
          "countryOfResidence": {
            "type": "string",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "address": {
            "$ref": "#/components/schemas/OfficerAddress"
          },
          "formerNames": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "occupation": {
            "type": "string",
            "nullable": true
          },
          "officerId": {
            "type": "string",
            "nullable": true
          },
          "appointmentsUrl": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "OfficerAddress": {
        "type": "object",
        "properties": {
          "addressLine1": {
            "type": "string",
            "nullable": true
          },
          "addressLine2": {
            "type": "string",
            "nullable": true
          },
          "locality": {
            "type": "string",
            "nullable": true
          },
          "premises": {
            "type": "string",
            "nullable": true
          },
          "postalCode": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "region": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "OnboardingTaskTemplateDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "billableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate."
          },
          "dueDateOffsetDays": {
            "type": "integer",
            "description": "Days after service start date for the task due date",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day stamped onto the start date of the created task.",
            "format": "time"
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day stamped onto the due date of the created task.",
            "format": "time"
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "assignedUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflow": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "category": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this onboarding task template",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this template is active"
          }
        },
        "additionalProperties": false,
        "description": "DTO for onboarding task templates, exposing only codes and enums (never DB IDs)."
      },
      "OnboardingTaskTemplateDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnboardingTaskTemplateDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "OnboardingTaskTemplateSortField": {
        "enum": [
          "DueDateOffsetDays",
          "Name"
        ],
        "type": "string",
        "example": "DueDateOffsetDays"
      },
      "OpenDocumentRequestRequest": {
        "type": "object",
        "properties": {
          "recipientEmails": {
            "type": "string",
            "description": "Comma-separated email addresses to send the document request to.\nAt least one is required.",
            "nullable": true
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for the chase frequency in days. If not specified, the tenant default is used;\n0 switches chasing off.",
            "format": "int32",
            "nullable": true
          },
          "scheduledAt": {
            "type": "string",
            "description": "When set, the request is not opened now: it stays Draft and a scheduled send opens it at\nthis UTC instant. Must be in the future. Omit to open and send immediately.",
            "format": "date-time",
            "nullable": true
          },
          "composedEmail": {
            "$ref": "#/components/schemas/ComposedEmail"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for opening (sending to client) a document request.\nRequires at least one recipient email address."
      },
      "OpenRouterChoice": {
        "type": "object",
        "properties": {
          "message": {
            "$ref": "#/components/schemas/OpenRouterMessage"
          },
          "finish_reason": {
            "type": "string",
            "description": "Why the model stopped: \"stop\" when it finished, \"length\" when it reached the token limit, \"error\" when the\nprovider failed part-way",
            "nullable": true
          },
          "error": {
            "$ref": "#/components/schemas/OpenRouterError"
          }
        },
        "additionalProperties": false,
        "description": "A completion choice from the AI model"
      },
      "OpenRouterError": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "nullable": true
          },
          "type": {
            "type": "string",
            "description": "The error type",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Error information from OpenRouter"
      },
      "OpenRouterMessage": {
        "type": "object",
        "properties": {
          "content": {
            "type": "string",
            "description": "The generated text content",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Message content from the AI model"
      },
      "OpenRouterResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The response ID from OpenRouter",
            "nullable": true
          },
          "choices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpenRouterChoice"
            },
            "description": "List of completion choices returned by the AI model",
            "nullable": true
          },
          "usage": {
            "$ref": "#/components/schemas/OpenRouterUsage"
          },
          "error": {
            "$ref": "#/components/schemas/OpenRouterError"
          }
        },
        "additionalProperties": false,
        "description": "Response from OpenRouter API for AI generation requests"
      },
      "OpenRouterUsage": {
        "type": "object",
        "properties": {
          "prompt_tokens": {
            "type": "integer",
            "description": "Number of tokens used in the prompt",
            "format": "int32"
          },
          "completion_tokens": {
            "type": "integer",
            "description": "Number of tokens generated in the completion",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Token usage statistics for the AI request"
      },
      "OtherCapitalGains": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "cryptoassets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CryptoassetDisposal"
            },
            "nullable": true
          },
          "otherGains": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OtherGainDisposal"
            },
            "nullable": true
          },
          "unlistedShares": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UnlistedSharesDisposal"
            },
            "nullable": true
          },
          "gainsFromExcludedIndexedSecurities": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "qualifyingAssetHoldingCompany": {
            "$ref": "#/components/schemas/QahcGains"
          },
          "nonStandardGains": {
            "$ref": "#/components/schemas/NonStandardGains"
          },
          "losses": {
            "$ref": "#/components/schemas/CapitalLosses"
          },
          "adjustments": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "lifetimeAllowance": {
            "$ref": "#/components/schemas/LifetimeAllowances"
          }
        },
        "additionalProperties": false
      },
      "OtherEmailAddressDto": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "description": "The address, lower case",
            "nullable": true
          },
          "clientMatches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAddressClientMatchDto"
            },
            "description": "Clients this address is also on, as the client's own email or a contact's: a clash to sort out, since staff\naddresses are never matched to a client",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One of a team member's other email addresses"
      },
      "OtherEmploymentIncome": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "shareOption": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ShareOptionItem"
            },
            "nullable": true
          },
          "sharesAwardedOrReceived": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SharesAwardedOrReceivedItem"
            },
            "nullable": true
          },
          "disability": {
            "$ref": "#/components/schemas/EmploymentDeductionItem"
          },
          "foreignService": {
            "$ref": "#/components/schemas/EmploymentDeductionItem"
          },
          "lumpSums": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmploymentLumpSums"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "OtherGainDisposal": {
        "type": "object",
        "properties": {
          "assetType": {
            "type": "string",
            "nullable": true
          },
          "numberOfDisposals": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "assetDescription": {
            "type": "string",
            "nullable": true
          },
          "companyName": {
            "type": "string",
            "nullable": true
          },
          "companyRegistrationNumber": {
            "type": "string",
            "nullable": true
          },
          "acquisitionDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "disposalDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "disposalProceeds": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "allowableCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsWithBadr": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsWithInv": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsBeforeLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "losses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "claimOrElectionCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "amountOfNetGain": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountOfNetLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "rttTaxPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "OtherReliefs": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "nonDeductibleLoanInterest": {
            "$ref": "#/components/schemas/ReliefClaim"
          },
          "payrollGiving": {
            "$ref": "#/components/schemas/ReliefClaim"
          },
          "qualifyingDistributionRedemptionOfSharesAndSecurities": {
            "$ref": "#/components/schemas/ReliefAmount"
          },
          "maintenancePayments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MaintenancePayment"
            },
            "nullable": true
          },
          "postCessationTradeReliefAndCertainOtherLosses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PostCessationRelief"
            },
            "nullable": true
          },
          "annualPaymentsMade": {
            "$ref": "#/components/schemas/ReliefClaim"
          },
          "qualifyingLoanInterestPayments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QualifyingLoanInterest"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "OtherSavingsIncome": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "securities": {
            "$ref": "#/components/schemas/SecuritiesIncome"
          },
          "foreignInterest": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignInterestItem"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "OutboundWebhookAttemptOutcome": {
        "enum": [
          "Succeeded",
          "HttpError",
          "Timeout",
          "ConnectionFailed",
          "BlockedTarget"
        ],
        "type": "string",
        "example": "Succeeded"
      },
      "OutboundWebhookAttemptTrigger": {
        "enum": [
          "Automatic",
          "Manual",
          "Test"
        ],
        "type": "string",
        "example": "Automatic"
      },
      "OutboundWebhookCreatedDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The webhook's id.",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "What the practice calls it.",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "Where events are posted.",
            "nullable": true
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The event types it wants, or `*` alone for everything.",
            "nullable": true
          },
          "payloadMode": {
            "$ref": "#/components/schemas/OutboundWebhookPayloadMode"
          },
          "isEnabled": {
            "type": "boolean",
            "description": "Whether events are sent to it."
          },
          "disabledReason": {
            "$ref": "#/components/schemas/OutboundWebhookDisabledReason"
          },
          "disabledDate": {
            "type": "string",
            "description": "When it was switched off; null while enabled.",
            "format": "date-time",
            "nullable": true
          },
          "health": {
            "$ref": "#/components/schemas/OutboundWebhookHealthDto"
          },
          "currentSecretCreatedDate": {
            "type": "string",
            "description": "When the current signing secret was issued.",
            "format": "date-time",
            "nullable": true
          },
          "previousSecretExpiresDate": {
            "type": "string",
            "description": "When the secret before it stops being valid; null outside a rotation's overlap.",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When it was created.",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When it was last changed.",
            "format": "date-time",
            "nullable": true
          },
          "secret": {
            "type": "string",
            "description": "The signing secret (`whsec_…`). Show it once; it cannot be read again.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A new webhook with its signing secret: the only time, besides a rotation, the secret is returned."
      },
      "OutboundWebhookDeliveryAttemptDto": {
        "type": "object",
        "properties": {
          "attemptNumber": {
            "type": "integer",
            "description": "1 for the first attempt.",
            "format": "int32"
          },
          "trigger": {
            "$ref": "#/components/schemas/OutboundWebhookAttemptTrigger"
          },
          "outcome": {
            "$ref": "#/components/schemas/OutboundWebhookAttemptOutcome"
          },
          "statusCode": {
            "type": "integer",
            "description": "The HTTP status, when the receiver answered.",
            "format": "int32",
            "nullable": true
          },
          "responseBody": {
            "type": "string",
            "description": "The first part of the receiver's answer.",
            "nullable": true
          },
          "startedDate": {
            "type": "string",
            "description": "When the attempt started.",
            "format": "date-time"
          },
          "durationMs": {
            "type": "integer",
            "description": "How long it took, in milliseconds.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One HTTP attempt of a delivery."
      },
      "OutboundWebhookDeliveryDetailDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The delivery's id.",
            "format": "uuid"
          },
          "webhookId": {
            "type": "string",
            "description": "The webhook it goes to.",
            "format": "uuid"
          },
          "eventId": {
            "type": "string",
            "description": "The event's id: the `webhook-id` header, the same on every attempt, for the receiver to skip repeats.",
            "format": "uuid"
          },
          "eventType": {
            "type": "string",
            "description": "The event type.",
            "nullable": true
          },
          "isTest": {
            "type": "boolean",
            "description": "Whether it is a test event sent from the test route."
          },
          "status": {
            "$ref": "#/components/schemas/OutboundWebhookDeliveryStatus"
          },
          "attemptCount": {
            "type": "integer",
            "description": "Attempts made so far.",
            "format": "int32"
          },
          "nextAttemptDate": {
            "type": "string",
            "description": "When the next attempt is due; null once it is finished.",
            "format": "date-time",
            "nullable": true
          },
          "lastStatusCode": {
            "type": "integer",
            "description": "The HTTP status of the last attempt, when the receiver answered.",
            "format": "int32",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When it was created.",
            "format": "date-time"
          },
          "completedDate": {
            "type": "string",
            "description": "When it succeeded, failed for good or was cancelled.",
            "format": "date-time",
            "nullable": true
          },
          "payloadMode": {
            "$ref": "#/components/schemas/OutboundWebhookPayloadMode"
          },
          "payload": {
            "type": "string",
            "description": "The exact body this delivery sends, as a string.",
            "nullable": true
          },
          "attempts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OutboundWebhookDeliveryAttemptDto"
            },
            "description": "The attempts, oldest first.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A delivery with the exact body it sends and every attempt made."
      },
      "OutboundWebhookDeliveryDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The delivery's id.",
            "format": "uuid"
          },
          "webhookId": {
            "type": "string",
            "description": "The webhook it goes to.",
            "format": "uuid"
          },
          "eventId": {
            "type": "string",
            "description": "The event's id: the `webhook-id` header, the same on every attempt, for the receiver to skip repeats.",
            "format": "uuid"
          },
          "eventType": {
            "type": "string",
            "description": "The event type.",
            "nullable": true
          },
          "isTest": {
            "type": "boolean",
            "description": "Whether it is a test event sent from the test route."
          },
          "status": {
            "$ref": "#/components/schemas/OutboundWebhookDeliveryStatus"
          },
          "attemptCount": {
            "type": "integer",
            "description": "Attempts made so far.",
            "format": "int32"
          },
          "nextAttemptDate": {
            "type": "string",
            "description": "When the next attempt is due; null once it is finished.",
            "format": "date-time",
            "nullable": true
          },
          "lastStatusCode": {
            "type": "integer",
            "description": "The HTTP status of the last attempt, when the receiver answered.",
            "format": "int32",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When it was created.",
            "format": "date-time"
          },
          "completedDate": {
            "type": "string",
            "description": "When it succeeded, failed for good or was cancelled.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One event's delivery to one of the practice's webhooks."
      },
      "OutboundWebhookDeliveryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OutboundWebhookDeliveryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "OutboundWebhookDeliveryStatus": {
        "enum": [
          "Pending",
          "Retrying",
          "Succeeded",
          "Failed",
          "Cancelled"
        ],
        "type": "string",
        "example": "Pending"
      },
      "OutboundWebhookDisabledReason": {
        "enum": [
          "Manual",
          "Failing",
          "Gone"
        ],
        "type": "string",
        "example": "Manual"
      },
      "OutboundWebhookDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The webhook's id.",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "What the practice calls it.",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "Where events are posted.",
            "nullable": true
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The event types it wants, or `*` alone for everything.",
            "nullable": true
          },
          "payloadMode": {
            "$ref": "#/components/schemas/OutboundWebhookPayloadMode"
          },
          "isEnabled": {
            "type": "boolean",
            "description": "Whether events are sent to it."
          },
          "disabledReason": {
            "$ref": "#/components/schemas/OutboundWebhookDisabledReason"
          },
          "disabledDate": {
            "type": "string",
            "description": "When it was switched off; null while enabled.",
            "format": "date-time",
            "nullable": true
          },
          "health": {
            "$ref": "#/components/schemas/OutboundWebhookHealthDto"
          },
          "currentSecretCreatedDate": {
            "type": "string",
            "description": "When the current signing secret was issued.",
            "format": "date-time",
            "nullable": true
          },
          "previousSecretExpiresDate": {
            "type": "string",
            "description": "When the secret before it stops being valid; null outside a rotation's overlap.",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When it was created.",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When it was last changed.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A practice's webhook. Never carries its signing secret: that is returned only when it is created or rotated."
      },
      "OutboundWebhookDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OutboundWebhookDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "OutboundWebhookEventTypeDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "The event type's name, as a subscription names it and the receiver sees it in `type` (e.g. `client.created`).",
            "nullable": true
          },
          "label": {
            "type": "string",
            "description": "A short label for the settings screen.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "One line saying when the event is sent.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One event SodiumHQ can send to a webhook."
      },
      "OutboundWebhookHealthDto": {
        "type": "object",
        "properties": {
          "consecutiveFailures": {
            "type": "integer",
            "description": "Failed attempts in a row, across all its deliveries, since the last success.",
            "format": "int32"
          },
          "failingSince": {
            "type": "string",
            "description": "The first failure since the last success; null while healthy. Failing for too long switches it off.",
            "format": "date-time",
            "nullable": true
          },
          "coolingDownUntil": {
            "type": "string",
            "description": "Until when deliveries to it are held back after repeated failures; null when it is not cooling down.",
            "format": "date-time",
            "nullable": true
          },
          "lastSuccessDate": {
            "type": "string",
            "description": "The last attempt its receiver answered 2xx.",
            "format": "date-time",
            "nullable": true
          },
          "lastFailureDate": {
            "type": "string",
            "description": "The last attempt that failed.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "How a webhook's receiver has been answering."
      },
      "OutboundWebhookPayloadMode": {
        "enum": [
          "Full",
          "Thin"
        ],
        "type": "string",
        "example": "Full"
      },
      "OutboundWebhookRotatedSecretDto": {
        "type": "object",
        "properties": {
          "secret": {
            "type": "string",
            "description": "The new secret (`whsec_…`). Show it once; it cannot be read again.",
            "nullable": true
          },
          "previousSecretExpiresDate": {
            "type": "string",
            "description": "Until when the secret it replaces is still valid: deliveries are signed with both until then.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "A webhook's new signing secret."
      },
      "OutstandingClientRequestType": {
        "enum": [
          "DocumentRequest",
          "DataForm",
          "DocumentApproval",
          "ClientConfirmation",
          "CisPayments",
          "CisReturnConfirmation"
        ],
        "type": "string",
        "example": "DocumentRequest"
      },
      "PackageDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this package",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name of the package",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Detailed description of the package and its features",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "When true, prevents new tenants from being assigned to this package"
          },
          "moduleCount": {
            "type": "integer",
            "description": "Number of modules included in this package",
            "format": "int32"
          },
          "tenantCount": {
            "type": "integer",
            "description": "Number of tenants assigned to this package",
            "format": "int32"
          },
          "modules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Collection of modules included in this package",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the package was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the package was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A system-level collection of modules that can be assigned to a tenant"
      },
      "PageSelection": {
        "enum": [
          "None",
          "AllPages",
          "FirstPageOnly",
          "AllExceptFirstPage"
        ],
        "type": "string",
        "example": "None"
      },
      "PatchExternalMeetingNoteRequest": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client to put the note on: files an unmatched note, or moves a matched one. Null takes a matched note off its\nclient, back to Unmatched.",
            "nullable": true
          },
          "taskCode": {
            "type": "string",
            "description": "The client's task the meeting was about. Null removes the link. Needs the note to be on a client, and changing a\nmatched note's client removes the link unless a task of the new client is sent with it.",
            "nullable": true
          },
          "isIgnored": {
            "type": "boolean",
            "description": "True ignores the note, so no look-up or webhook offers it again (a matched note comes off its client first); false\nputs an ignored note back on the Unmatched list. Cannot be null.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Partial update for a meeting note from a note taker, following JSON Merge Patch: send only the fields to change.\nA field left out is not touched; `clientCode` and `taskCode` sent as null are cleared."
      },
      "PatchMailboxMessageRequest": {
        "required": [
          "isRead",
          "messageIds"
        ],
        "type": "object",
        "properties": {
          "messageIds": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The message UniqueIds to update"
          },
          "isRead": {
            "type": "boolean",
            "description": "Whether the messages should be marked as read"
          }
        },
        "additionalProperties": false,
        "description": "Request to bulk-update mailbox message properties (e.g., mark as read/unread)"
      },
      "PatchTaskItemRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the task. Required, so it cannot be cleared or blank.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The description of the task. Null clears it.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "startDate": {
            "type": "string",
            "description": "When the task starts. Required, so it cannot be cleared.",
            "format": "date",
            "nullable": true
          },
          "dueDate": {
            "type": "string",
            "description": "When the task is due. Required, so it cannot be cleared.",
            "format": "date",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "Time of day on the start date. Cannot be cleared.",
            "format": "time",
            "nullable": true
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day on the due date. Cannot be cleared.",
            "format": "time",
            "nullable": true
          },
          "statutoryDueDate": {
            "type": "string",
            "description": "The statutory due date for compliance tasks. Null clears it.",
            "format": "date",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes. Null clears it.",
            "format": "int32",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "The checklist, replacing the current one. Null or an empty list clears it.",
            "nullable": true
          },
          "clientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the clients on the task, replacing the current ones. The primary client always stays on\nthe task, so null or an empty list leaves just the primary client. To remove every client, clear the\nprimary client too.",
            "nullable": true
          },
          "primaryClientCode": {
            "type": "string",
            "description": "The code of the primary client. Null clears it, but a task never has only secondary clients, so if it\nstill has clients the first of them becomes primary. Changing the primary client also clears the task's\nservice and pipeline links, because they belong to a client, unless a service code is sent.",
            "nullable": true
          },
          "clientBillableServiceCode": {
            "type": "string",
            "description": "The code of the client billable service the task relates to. Null clears it.",
            "nullable": true
          },
          "assignedUserCode": {
            "type": "string",
            "description": "The code of the user the task is assigned to. Null unassigns it.",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "The code of the team the task is assigned to. Null removes the team.",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "The code of the task's category. Null clears it.",
            "nullable": true
          },
          "moveWorkflowStepDates": {
            "type": "boolean",
            "description": "When the start or due date changes, whether the task's dated workflow steps move with it\n(their planned dates are worked out again from their timings). Defaults to true when omitted or null.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Partial update for a task, following JSON Merge Patch: send only the fields to change.\nA field left out of the body is not touched, so a quick action never overwrites details it did not\nknow about, such as the description. A field sent as `null` is cleared, for the fields that can be\ncleared. The name, status, dates and times are required on a task, so sending one of those as\n`null` is rejected."
      },
      "PatchTenantUserRequest": {
        "type": "object",
        "properties": {
          "workingPatternCode": {
            "type": "string",
            "description": "The code of the working pattern to put this user on. Always applied — null clears it\nso the practice's default pattern applies.",
            "nullable": true
          },
          "isRestrictedToOwnTime": {
            "type": "boolean",
            "description": "Whether the user can only see and edit their own time entries.\nOmit (null) to leave the restriction unchanged.",
            "nullable": true
          },
          "isPaidForTrackedTime": {
            "type": "boolean",
            "description": "Whether the practice pays this user for their tracked time (contract basis).\nOmit (null) to leave the setting unchanged.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Partial update for a user within a tenant. Extend with further patchable fields as needed.\nRates are managed via the user's rates endpoints, not here."
      },
      "PayTimeEntriesRequest": {
        "required": [
          "timeEntryCodes"
        ],
        "type": "object",
        "properties": {
          "timeEntryCodes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the time entries to pay"
          }
        },
        "additionalProperties": false,
        "description": "Request to pay a batch of time entries on a new pay run. All entries must belong to the\nsame team member, who must be paid for tracked time; they must be unpaid, and every one\nmust carry a cost rate. Entries not yet approved for payment are approved as part of\npaying them."
      },
      "PayerDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Simplified DTO for displaying payer (customer) information.\nPayers are created by GoCardless via Billing Request Flow, so we only need read-only properties."
      },
      "PaymentMandateResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/PaymentMandateStatus"
          },
          "scheme": {
            "type": "string",
            "description": "The Direct Debit scheme (e.g., \"bacs\", \"sepa_core\").",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "The date and time when the mandate was created.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Response model representing a payment mandate."
      },
      "PaymentMandateStatus": {
        "enum": [
          "PendingCustomerApproval",
          "PendingSubmission",
          "Submitted",
          "Active",
          "Failed",
          "Cancelled",
          "Expired"
        ],
        "type": "string",
        "description": "Defines the status of a GoCardless Direct Debit mandate.\nMaps to GoCardless mandate statuses: pending_customer_approval, pending_submission,\nsubmitted, active, failed, cancelled, expired.",
        "example": "PendingCustomerApproval"
      },
      "PendingWorkflowStepDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The workflow step ID",
            "format": "int32"
          },
          "stepName": {
            "type": "string",
            "description": "The name of the workflow step",
            "nullable": true
          },
          "stepType": {
            "$ref": "#/components/schemas/WorkflowStepType"
          },
          "autoExecute": {
            "type": "boolean",
            "description": "True when the step runs by itself once its dependencies are met."
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "taskCategory": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "groupName": {
            "type": "string",
            "description": "The workflow group name",
            "nullable": true
          },
          "groupNumber": {
            "type": "integer",
            "description": "The group number within the workflow",
            "format": "int32"
          },
          "stepNumber": {
            "type": "integer",
            "description": "The step number within the group",
            "format": "int32"
          },
          "deadline": {
            "type": "string",
            "description": "The group's calculated deadline (from the task's due date + group interval)",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the step was created",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Lightweight projection of a manual-mode outbound workflow step that is ready to send.\nThese are steps where dependencies are met and a user needs to review and trigger the send."
      },
      "PendingWorkflowStepDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PendingWorkflowStepDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "PendingWorkflowStepSortField": {
        "enum": [
          "StepName",
          "Deadline",
          "ClientName",
          "StepType"
        ],
        "type": "string",
        "example": "StepName"
      },
      "PensionsReliefs": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "regularPensionContributions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "oneOffPensionContributionsPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "retirementAnnuityPayments": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "paymentToEmployersSchemeNoTaxRelief": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "overseasPensionSchemeContributions": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PeriodOfAccount": {
        "type": "object",
        "properties": {
          "startDate": {
            "type": "string",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "format": "date"
          }
        },
        "additionalProperties": false
      },
      "PeriodsOfAccountResponse": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time"
          },
          "hasPeriodsOfAccount": {
            "type": "boolean"
          },
          "periods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PeriodOfAccount"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PeriodsOfAccountResponseDto": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "description": "When the periods of account were last submitted to HMRC.",
            "format": "date-time"
          },
          "hasPeriodsOfAccount": {
            "type": "boolean",
            "description": "Whether the business draws its accounts to periods other than the tax year. False means it\nreports to the tax year and Sodium.HmrcMtd.Product.Contracts.Dtos.PeriodsOfAccountResponseDto.Periods is empty — HMRC omit the dates entirely in\nthat case, so an empty list here is an answer rather than missing data."
          },
          "periods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PeriodOfAccount"
            },
            "description": "The periods themselves, when the business has them.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The periods of account HMRC hold for one self-employment income source and tax year — the\naccounting periods the business actually draws its accounts to, which need not align with the\ntax year."
      },
      "Permission": {
        "enum": [
          "None",
          "ViewAll",
          "Create",
          "Update",
          "Delete",
          "Export",
          "Import",
          "Admin"
        ],
        "type": "string",
        "example": "None"
      },
      "PinnedNoteEntityType": {
        "enum": [
          "Client",
          "Task"
        ],
        "type": "string",
        "example": "Client"
      },
      "PipelineDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "isArchived": {
            "type": "boolean",
            "description": "Indicates whether this pipeline is archived (inactive)"
          },
          "defaultManagedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "showKanbanBoard": {
            "type": "boolean",
            "description": "Whether this pipeline should appear on the Boards kanban view"
          },
          "trackDealValue": {
            "type": "boolean",
            "description": "Whether cards on this pipeline carry a deal value and likelihood, with full and weighted totals on the board"
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PipelineStageDto"
            },
            "description": "User-defined stages for this pipeline",
            "nullable": true
          },
          "stageCount": {
            "type": "integer",
            "description": "The number of stages defined on this pipeline",
            "format": "int32"
          },
          "recurringTaskCount": {
            "type": "integer",
            "description": "The number of recurring tasks associated with this pipeline",
            "format": "int32"
          },
          "createdDate": {
            "type": "string",
            "description": "When the pipeline was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the pipeline was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for sales pipeline information"
      },
      "PipelineDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PipelineDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "PipelineOnboardingTaskTemplateDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "pipeline": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate."
          },
          "dueDateOffsetDays": {
            "type": "integer",
            "description": "Days after the card's start date for the task due date",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day stamped onto the start date of the created task.",
            "format": "time"
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day stamped onto the due date of the created task.",
            "format": "time"
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "assignedUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflow": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "category": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this intake task template",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this template is active"
          }
        },
        "additionalProperties": false,
        "description": "DTO for pipeline intake task templates, exposing only codes and enums (never DB IDs)."
      },
      "PipelineOnboardingTaskTemplateDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PipelineOnboardingTaskTemplateDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "PipelineOnboardingTaskTemplateSortField": {
        "enum": [
          "DueDateOffsetDays",
          "Name"
        ],
        "type": "string",
        "example": "DueDateOffsetDays"
      },
      "PipelineSortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "PipelineStageDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this stage",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of this stage",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional description of what this stage represents",
            "nullable": true
          },
          "icon": {
            "type": "string",
            "description": "Optional Lucide icon name for visual identification",
            "nullable": true
          },
          "color": {
            "type": "string",
            "description": "Optional hex colour for visual identification",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The display order for this stage",
            "format": "int32"
          },
          "showOnClientPage": {
            "type": "boolean",
            "description": "Whether a client's pipeline card is shown on their client page while it sits in this stage.\nDefaults to true; turn off for terminal stages (e.g. \"Won\")."
          }
        },
        "additionalProperties": false,
        "description": "DTO for a user-defined stage on a sales pipeline"
      },
      "PipelineStageValueTotalDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The stage code",
            "nullable": true
          },
          "totalValue": {
            "type": "number",
            "description": "Sum of the cards' values. Cards with no value count as zero.",
            "format": "double"
          },
          "weightedValue": {
            "type": "number",
            "description": "Sum of each card's value multiplied by its likelihood. Cards with no likelihood count as zero.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Deal value totals for one stage of a pipeline board, across every card in the stage that\nmatches the board's filters (not just the cards loaded on screen)."
      },
      "PlatformCapability": {
        "enum": [
          "None",
          "Accounting",
          "CRM",
          "DocumentManagement",
          "Communication",
          "ProjectManagement",
          "TimeTracking",
          "Payments",
          "ClientImport",
          "DirectDebit",
          "AML",
          "Proposals",
          "BookkeepingHealth",
          "ESignature",
          "MeetingNotes",
          "ClientSync"
        ],
        "type": "string",
        "example": "None"
      },
      "PortalAccessStatusDto": {
        "type": "object",
        "properties": {
          "hasPortalAccess": {
            "type": "boolean",
            "description": "Whether the contact currently has portal access on this client."
          },
          "portalUser": {
            "$ref": "#/components/schemas/PortalUserDto"
          },
          "willSendInvitationEmail": {
            "type": "boolean",
            "description": "Whether granting portal access would send an invitation email. False when the contact\nalready uses the portal — they simply see the client on their next visit."
          }
        },
        "additionalProperties": false,
        "description": "Portal access state for a contact on a client, including what granting access would do."
      },
      "PortalFolderDto": {
        "type": "object",
        "properties": {
          "folderId": {
            "type": "string",
            "description": "The external platform folder ID",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name of the folder",
            "nullable": true
          },
          "path": {
            "type": "string",
            "description": "Path to pass as portalFolderPath when drilling into this folder.\nFormat: \"/\" separated folder names, e.g. \"Tax Returns/2026\".",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A folder entry for portal document navigation.\nShared between the main API portal-view and client portal folder browsing."
      },
      "PortalUserDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying the portal user.",
            "nullable": true
          },
          "contactCode": {
            "type": "string",
            "description": "Code of the linked contact.",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The portal user's email address.",
            "nullable": true
          },
          "contactFirstName": {
            "type": "string",
            "description": "First name of the linked contact.",
            "nullable": true
          },
          "contactPreferredName": {
            "type": "string",
            "description": "Preferred name of the linked contact. Show it in place of the first name when set.",
            "nullable": true
          },
          "contactLastName": {
            "type": "string",
            "description": "Last name of the linked contact.",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether this portal user account is active."
          },
          "isEmailVerified": {
            "type": "boolean",
            "description": "Whether the user's email address has been verified."
          },
          "lastLoginDate": {
            "type": "string",
            "description": "When the portal user last logged in.",
            "format": "date-time",
            "nullable": true
          },
          "invitationSentDate": {
            "type": "string",
            "description": "When the portal invitation email was last sent.",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the portal user was created.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "A contact who has been granted access to the client portal."
      },
      "PortalUserDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortalUserDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "PortalUserSortField": {
        "enum": [
          "Name",
          "Email",
          "LastLoginDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "PostCessationRelief": {
        "type": "object",
        "properties": {
          "customerReference": {
            "type": "string",
            "nullable": true
          },
          "businessName": {
            "type": "string",
            "nullable": true
          },
          "dateBusinessCeased": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "natureOfTrade": {
            "type": "string",
            "nullable": true
          },
          "incomeSource": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PpdMultiplePropertyDisposal": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "nullable": true
          },
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "ppdSubmissionId": {
            "type": "string",
            "nullable": true
          },
          "ppdSubmissionDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "numberOfDisposals": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "disposalTaxYear": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "completionDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "gainsWithBadr": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsWithInv": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountOfNetGain": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountOfNetLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PpdSinglePropertyDisposal": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "nullable": true
          },
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "ppdSubmissionId": {
            "type": "string",
            "nullable": true
          },
          "ppdSubmissionDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "disposalDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "completionDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "disposalProceeds": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "acquisitionDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "acquisitionAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "improvementCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "additionalCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "prfAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherReliefAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsWithBadr": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsWithInv": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "lossesFromThisYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "lossesFromPreviousYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountOfNetGain": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountOfNetLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PracticeDetailsDto": {
        "required": [
          "currencyCode",
          "locale",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "Official name of the accounting practice or firm"
          },
          "isVatRegistered": {
            "type": "boolean",
            "description": "Whether the practice is registered for VAT"
          },
          "vatNumber": {
            "maxLength": 20,
            "type": "string",
            "description": "The practice's own VAT registration number. When set, client VAT number checks against HMRC\nbecome verified checks and return a consultation number as proof of the check.",
            "nullable": true
          },
          "companyNumber": {
            "type": "string",
            "description": "Companies House registration number (if the practice is a limited company)",
            "nullable": true
          },
          "logoUrl": {
            "type": "string",
            "description": "URL to the practice logo image (from image assets)",
            "nullable": true
          },
          "address": {
            "type": "string",
            "description": "Practice physical/postal address",
            "nullable": true
          },
          "website": {
            "type": "string",
            "description": "Practice website URL",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "Practice email address for general inquiries",
            "format": "email",
            "nullable": true
          },
          "mobile": {
            "type": "string",
            "description": "Practice mobile phone number",
            "nullable": true
          },
          "telephone": {
            "type": "string",
            "description": "Practice landline telephone number",
            "nullable": true
          },
          "professionalBody": {
            "$ref": "#/components/schemas/ProfessionalBody"
          },
          "professionalBodyName": {
            "type": "string",
            "description": "Full name of the professional body (e.g. \"Institute of Chartered Accountants in England and Wales\"). Derived from ProfessionalBody.",
            "nullable": true,
            "readOnly": true
          },
          "professionalBodyWebsite": {
            "type": "string",
            "description": "Public website URL for the professional body (e.g. \"https://www.icaew.com\"). Derived from ProfessionalBody.",
            "nullable": true,
            "readOnly": true
          },
          "currencyCode": {
            "maxLength": 3,
            "minLength": 1,
            "type": "string",
            "description": "ISO 4217 currency code the practice bills in (e.g. \"GBP\"). Drives money formatting across\ndocuments, emails, the web app and the client portal. Defaults to GBP."
          },
          "locale": {
            "maxLength": 20,
            "minLength": 1,
            "type": "string",
            "description": "BCP 47 / .NET culture name (e.g. \"en-GB\") driving number grouping and date conventions.\nDefaults to en-GB."
          },
          "vatRegime": {
            "$ref": "#/components/schemas/VatRegime"
          },
          "logo": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "Core practice/firm information for the accounting practice or professional services firm.\nUsed for branding, contact details, and professional membership information that appears on proposals,\nengagement letters, and other client-facing documents."
      },
      "PracticeDocumentDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Name of the document",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Description of the document",
            "nullable": true
          },
          "originalFileName": {
            "type": "string",
            "description": "Original file name provided during upload",
            "nullable": true
          },
          "contentType": {
            "type": "string",
            "description": "MIME type of the file",
            "nullable": true
          },
          "fileSize": {
            "type": "integer",
            "description": "File size in bytes",
            "format": "int64"
          },
          "createdDate": {
            "type": "string",
            "description": "Date when the document was uploaded",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "Date when the document was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Data transfer object for a practice document (tenant-level document library file)"
      },
      "PracticeDocumentDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PracticeDocumentDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "PracticeDocumentSortField": {
        "enum": [
          "Name",
          "FileSize",
          "CreatedDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "PracticeMessagingDto": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/PracticeMessagingStatus"
          },
          "isServiceAvailable": {
            "type": "boolean",
            "description": "False when messaging is unavailable, or when the Messaging Service could not be reached for the\nsenders (which are then null). The rest is still the practice's own state."
          },
          "enabledDate": {
            "type": "string",
            "description": "When messaging was switched on; null while it is off",
            "format": "date-time",
            "nullable": true
          },
          "enabledByUserName": {
            "type": "string",
            "description": "Who switched messaging on; null while it is off",
            "nullable": true
          },
          "senders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PracticeMessagingSenderDto"
            },
            "description": "The numbers the practice sends from, one per channel at most. Null when not read: before the\npractice's messaging account is set up, or while the service is unreachable.",
            "nullable": true
          },
          "numberApplication": {
            "$ref": "#/components/schemas/PracticeMessagingNumberApplicationDto"
          },
          "whatsApp": {
            "$ref": "#/components/schemas/PracticeMessagingWhatsAppDto"
          },
          "hasConversations": {
            "type": "boolean",
            "description": "The practice has message conversations. They are kept when its number is cancelled, so their history stays\nvisible with no number."
          },
          "hasPayableMandate": {
            "type": "boolean",
            "description": "The practice has a Direct Debit that can collect (active, or new and not yet collected on). Applying for a number,\nbuying credits and switching on automatic top-up need one: without it they are a 409 billing_mandate_required.\nNull when not known: messaging is unavailable, Account Hub could not be reached, or this is the answer of a change\nrather than the read.",
            "nullable": true
          },
          "twilioAccountSid": {
            "type": "string",
            "description": "The practice's Twilio subaccount SID (AC...). Only the superadmin read sets it; null on the practice's own routes,\nbefore the practice is set up, or while the service is unreachable.",
            "nullable": true
          },
          "quietHours": {
            "$ref": "#/components/schemas/MessagingQuietHoursDto"
          },
          "textWordings": {
            "$ref": "#/components/schemas/MessagingTextWordingsDto"
          },
          "requestTextRouting": {
            "$ref": "#/components/schemas/MessagingRequestTextRouting"
          }
        },
        "additionalProperties": false,
        "description": "The practice's client messaging (SMS and WhatsApp): where it is with switching it on, and the\nnumbers it sends from."
      },
      "PracticeMessagingNumberApplicationDto": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/MessagingNumberApplicationStatus"
          },
          "submittedDate": {
            "type": "string",
            "description": "When it was submitted to the review; null until then",
            "format": "date-time",
            "nullable": true
          },
          "reviewedDate": {
            "type": "string",
            "description": "When the review approved or rejected it; null until then",
            "format": "date-time",
            "nullable": true
          },
          "rejectionReasons": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Why it was turned down, in the reviewer's words; empty unless rejected",
            "nullable": true
          },
          "requestedPhoneNumber": {
            "type": "string",
            "description": "The number the practice asked for, E.164, if any",
            "nullable": true
          },
          "phoneNumber": {
            "type": "string",
            "description": "The number bought, E.164; null until then",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Where the practice's application for its own number is"
      },
      "PracticeMessagingSenderDto": {
        "type": "object",
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "address": {
            "type": "string",
            "description": "The number, E.164",
            "nullable": true
          },
          "isOwnedNumber": {
            "type": "boolean",
            "description": "Whether the practice's own messaging account owns the number; false for the shared WhatsApp\nSandbox"
          },
          "isSandbox": {
            "type": "boolean",
            "description": "Whether the number is the shared WhatsApp Sandbox: a WhatsApp sender that is not registered on WhatsApp in the\npractice's own account. Always false for SMS."
          }
        },
        "additionalProperties": false,
        "description": "The number a practice sends from on one channel"
      },
      "PracticeMessagingStatus": {
        "enum": [
          "Unavailable",
          "Off",
          "SettingUp",
          "AwaitingNumber",
          "Active"
        ],
        "type": "string",
        "example": "Unavailable"
      },
      "PracticeMessagingWhatsAppDto": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/MessagingWhatsAppStatus"
          },
          "address": {
            "type": "string",
            "description": "The number connected, E.164",
            "nullable": true
          },
          "displayName": {
            "type": "string",
            "description": "The display name WhatsApp shows, which Meta reviews",
            "nullable": true
          },
          "displayNameStatus": {
            "type": "string",
            "description": "Meta's review of the display name as Twilio reports it (e.g. PENDING, APPROVED); null until it reports one",
            "nullable": true
          },
          "offlineReasons": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Why the sender is not online, in Meta's words; empty when none",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the practice connected (UTC)",
            "format": "date-time"
          },
          "onlineDate": {
            "type": "string",
            "description": "When the number came online on WhatsApp (UTC); null until then",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The practice's WhatsApp connection of its own number"
      },
      "PracticeNoteDto": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "The note content. Empty when nothing has been written yet.",
            "nullable": true
          },
          "isRichText": {
            "type": "boolean",
            "description": "Whether SodiumHQ.DTOs.PracticeNote.PracticeNoteDto.Text is HTML from the rich-text editor rather than plain text"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the note was last saved; null when nothing has been written yet. Doubles as the\nversion a save is made against - send it back as ExpectedUpdatedDate.",
            "format": "date-time",
            "nullable": true
          },
          "updatedByName": {
            "type": "string",
            "description": "Who last saved the note; null when nothing has been written yet",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for the practice's shared note"
      },
      "PracticeWhatsAppDisconnectedDto": {
        "type": "object",
        "properties": {
          "notice": {
            "type": "string",
            "description": "What the practice must do before connecting the number again: turn off two-step verification for it in WhatsApp\nManager",
            "nullable": true
          },
          "messaging": {
            "$ref": "#/components/schemas/PracticeMessagingDto"
          }
        },
        "additionalProperties": false,
        "description": "The practice's WhatsApp disconnected"
      },
      "PresetDateRange": {
        "enum": [
          "ThisWeek",
          "NextWeek",
          "Last7Days",
          "Next7Days",
          "Last30Days",
          "Next30Days",
          "PreviousMonth",
          "ThisMonth",
          "NextMonth",
          "PreviousQuarter",
          "ThisQuarter",
          "NextQuarter",
          "PreviousYear",
          "ThisYear",
          "NextYear",
          "YearToDate",
          "PreviousTaxYear",
          "ThisTaxYear",
          "NextTaxYear",
          "TaxYearToDate",
          "Today",
          "PreviousWeek",
          "TodayOnwards",
          "Last12Months",
          "Last12FullMonths",
          "CustomDateRange"
        ],
        "type": "string",
        "example": "ThisWeek"
      },
      "PreviewApprovalDocument": {
        "required": [
          "title"
        ],
        "type": "object",
        "properties": {
          "title": {
            "minLength": 1,
            "type": "string",
            "description": "The document's title."
          },
          "summary": {
            "type": "string",
            "description": "The document's description.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A document that is not on the client yet, as an approval email will describe it."
      },
      "PreviewClientApprovalEmailRequest": {
        "type": "object",
        "properties": {
          "documentCodes": {
            "maxItems": 50,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of documents already on the client, in the order the email lists them.",
            "nullable": true
          },
          "newDocuments": {
            "maxItems": 50,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PreviewApprovalDocument"
            },
            "description": "Documents queued for upload that do not exist yet, listed after SodiumHQ.DTOs.ClientDocument.PreviewClientApprovalEmailRequest.DocumentCodes.",
            "nullable": true
          },
          "recipientEmails": {
            "type": "string",
            "description": "Comma-separated email addresses the request will go to. The first decides who the email greets.",
            "nullable": true
          },
          "message": {
            "type": "string",
            "description": "Optional message for the client, as HTML, shown in place of the documents' descriptions. May contain template tokens.",
            "nullable": true
          },
          "taskCode": {
            "type": "string",
            "description": "The task, when sending from a workflow step. With the group and step numbers, it decides the period tokens and the suggested sender.",
            "nullable": true
          },
          "groupNumber": {
            "type": "integer",
            "description": "The workflow group number of the step being sent from.",
            "format": "int32",
            "nullable": true
          },
          "stepNumber": {
            "type": "integer",
            "description": "The step number within that group.",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What an approval email is being previewed for. Nothing is created or sent."
      },
      "PreviewHmrcClientListRequest": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "maxLength": 5000000,
            "minLength": 1,
            "type": "string",
            "description": "The file's text, unchanged. Which list it is (SA, CT, PAYE or CIS) is read from its headers."
          }
        },
        "additionalProperties": false,
        "description": "An HMRC client list CSV, as downloaded from HMRC Online Services for Agents."
      },
      "PreviewOpenDocumentRequestEmailRequest": {
        "type": "object",
        "properties": {
          "recipientEmails": {
            "type": "string",
            "description": "Comma-separated email addresses the request will go to. The first decides who the email greets.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Who a draft request's email is being previewed for. Nothing is opened or sent."
      },
      "PreviewWorkflowStepEmailRequest": {
        "required": [
          "clientCode",
          "startDate",
          "stepConfig"
        ],
        "type": "object",
        "properties": {
          "stepConfig": {
            "$ref": "#/components/schemas/EmailStepConfigDto"
          },
          "clientCode": {
            "maxLength": 50,
            "minLength": 1,
            "type": "string",
            "description": "The client to render the email for. Tokens resolve against this client's data."
          },
          "startDate": {
            "type": "string",
            "description": "The task start date to anchor the preview on. Date tokens (VAT period, tax quarter, tax month,\ncalendar month and quarter) resolve relative to it, exactly as they would for a task started\non that date.",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "Previews the email of a SendEmail workflow step while it is being built, before the workflow is\nsaved and before any task exists.\n            \nA workflow is a practice-wide template with no client and no dates of its own, and one template\nfans out to many clients, so the preview cannot infer its context: the client and the task start\ndate are supplied here instead."
      },
      "PreviewWorkflowStepTextRequest": {
        "required": [
          "stepConfig"
        ],
        "type": "object",
        "properties": {
          "stepConfig": {
            "$ref": "#/components/schemas/SendTextMessageStepConfigDto"
          },
          "clientCode": {
            "maxLength": 50,
            "type": "string",
            "description": "The client to render the text for. Without one, only the practice and date tokens are filled.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Previews a Send Text Message step's text while it is being built in the workflow editor, before the workflow is\nsaved and before any task exists"
      },
      "PriceAdjustmentType": {
        "enum": [
          "Percentage",
          "FixedAmount"
        ],
        "type": "string",
        "example": "Percentage"
      },
      "PricingBasis": {
        "enum": [
          "Fixed",
          "PerHour",
          "PerDay",
          "PerUnit"
        ],
        "type": "string",
        "example": "Fixed"
      },
      "PricingFactorDto": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "description": "The description of the pricing factor (e.g., \"What bookkeeping software does the client use?\")",
            "nullable": true
          },
          "adjustmentType": {
            "$ref": "#/components/schemas/PriceAdjustmentType"
          },
          "options": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PricingFactorOptionDto"
            },
            "description": "The available options for this pricing factor",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for pricing factor information"
      },
      "PricingFactorOptionDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the option (e.g., \"None\", \"Xero\", \"Good\", \"Bad\")",
            "nullable": true
          },
          "value": {
            "type": "number",
            "description": "The value adjustment for this option. Interpretation depends on the parent factor's AdjustmentType:\nPercentage → multiplier (0.4 = +40%, -0.2 = -20%); FixedAmount → absolute currency (10 = +£10).",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "DTO for pricing factor option information"
      },
      "PricingTierDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this pricing tier",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name of the pricing tier",
            "nullable": true
          },
          "minClients": {
            "type": "integer",
            "description": "Minimum number of clients for this tier",
            "format": "int32"
          },
          "maxClients": {
            "type": "integer",
            "description": "Maximum number of clients for this tier (null for unlimited)",
            "format": "int32",
            "nullable": true
          },
          "monthlyPricePence": {
            "type": "integer",
            "description": "Monthly price in pence",
            "format": "int32"
          },
          "isPrivate": {
            "type": "boolean",
            "description": "Whether this tier is private. Private tiers can only be assigned by SuperAdmins.\nOmitted from response when false."
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for pricing tier information"
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "ProcessConfigDto": {
        "type": "object",
        "properties": {
          "workflow": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "checklist": {
            "$ref": "#/components/schemas/ChecklistDto"
          }
        },
        "additionalProperties": false,
        "description": "Groups the workflow and checklist applied to tasks created from a recurring task template.\nResponse shape - Workflow carries both code and name."
      },
      "ProcessConfigRequestDto": {
        "type": "object",
        "properties": {
          "workflowCode": {
            "type": "string",
            "description": "Code of the workflow template to apply to generated tasks.",
            "nullable": true
          },
          "checklist": {
            "$ref": "#/components/schemas/ChecklistDto"
          }
        },
        "additionalProperties": false,
        "description": "Groups the workflow and checklist applied to tasks created from a recurring task template.\nRequest shape - the workflow is referenced by code only."
      },
      "ProcessInvitationRequest": {
        "required": [
          "accept",
          "tenantCode",
          "token"
        ],
        "type": "object",
        "properties": {
          "token": {
            "minLength": 1,
            "type": "string",
            "description": "The invitation token received in the invitation email"
          },
          "tenantCode": {
            "minLength": 1,
            "type": "string",
            "description": "The tenant code that the user is being invited to"
          },
          "accept": {
            "type": "boolean",
            "description": "Whether to accept or decline the invitation"
          }
        },
        "additionalProperties": false,
        "description": "Request model for processing a user invitation response to join a tenant"
      },
      "ProcessInvitationResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Message indicating the result of the invitation processing",
            "nullable": true
          },
          "tenantCode": {
            "type": "string",
            "description": "The tenant code for the invitation",
            "nullable": true
          },
          "userCode": {
            "type": "string",
            "description": "The user's code within the tenant",
            "nullable": true
          },
          "status": {
            "type": "string",
            "description": "The current status of the invitation (Active or Declined)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model for processing an invitation (accept or decline)"
      },
      "ProductAccountUrlDto": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "The account's address in the other product's web app",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Where to open a client's account in another Sodium product"
      },
      "ProfessionalBody": {
        "enum": [
          "ICAEW",
          "ICAS",
          "CAI",
          "ACCA",
          "CIPFA",
          "CIMA",
          "AIA",
          "CIOT",
          "ATT",
          "AAT",
          "CPAA",
          "ICB",
          "IAB",
          "HMRC",
          "IFA",
          "ICPA"
        ],
        "type": "string",
        "example": "ICAEW"
      },
      "ProfessionalClearanceLetterSettingsDto": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Whether professional clearance letter functionality is enabled for this tenant"
          },
          "emailContentBlock": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "ccRecipientConfig": {
            "$ref": "#/components/schemas/EmailRecipientConfig"
          }
        },
        "additionalProperties": false,
        "description": "Tenant-level settings for professional clearance letters"
      },
      "ProfessionalClearanceRequestItemDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this professional clearance request",
            "nullable": true
          },
          "request": {
            "type": "string",
            "description": "The request text",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying the requests",
            "format": "int32"
          },
          "global": {
            "type": "boolean",
            "description": "If true, this item will be included for all clients regardless of the services they have"
          }
        },
        "additionalProperties": false,
        "description": "An individual item within a professional clearance request during client onboarding"
      },
      "ProfessionalClearanceRequestItemDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProfessionalClearanceRequestItemDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ProfessionalClearanceRequestItemSortField": {
        "enum": [
          "SortOrder"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "ProposalCatchUpCosts": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "description": "The practice's name for a catch-up fee (EngagementSettings.CatchUpFeeLabel), e.g. \"Catch-up fee\".",
            "nullable": true
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProposalCostRow"
            },
            "description": "One row per standalone service with a catch-up fee, in service order, then one per\npackage-priced package whose members carry one.",
            "nullable": true
          },
          "total": {
            "type": "number",
            "description": "Sum of the catch-up fees excluding VAT.",
            "format": "double"
          },
          "totalVat": {
            "type": "number",
            "description": "VAT on the catch-up fees.",
            "format": "double"
          },
          "instalments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProposalCatchUpInstalment"
            },
            "description": "The payment plan: what will be billed on each date, across every catch-up fee, in date\norder. Instalments falling on the same date are summed. Projected from each service's start\ndate and the client's invoice day the way the schedule builder places them, so a proposal\nshows the plan before it is accepted.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The catch-up fees on a proposal, for the optional \"Proposal - Catch-up fees\" content block."
      },
      "ProposalCatchUpInstalment": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "The date the amount is billed.",
            "format": "date"
          },
          "amount": {
            "type": "number",
            "description": "The amount billed on that date, excluding VAT.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "One billing date in a proposal's catch-up payment plan."
      },
      "ProposalCostGroup": {
        "type": "object",
        "properties": {
          "frequency": {
            "type": "string",
            "description": "Display label: \"Monthly\", \"Quarterly\", \"Annual\" or \"One-off\".",
            "nullable": true
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProposalCostRow"
            },
            "description": "Rows in render order: package rows, then standalone services, then setup fees (One-off\ngroup only). Catch-up fees are not here; see SodiumHQ.DTOs.DocumentTemplate.ProposalCosts.CatchUp.",
            "nullable": true
          },
          "subtotal": {
            "type": "number",
            "description": "Sum of row amounts excluding VAT. Open-ended per-unit rows contribute 0.",
            "format": "double"
          },
          "totalVat": {
            "type": "number",
            "description": "Sum of row VAT amounts.",
            "format": "double"
          },
          "grandTotal": {
            "type": "number",
            "description": "Subtotal + TotalVat.",
            "format": "double"
          },
          "showTotals": {
            "type": "boolean",
            "description": "True when the totals row should render: the group has more than one row. Whether the\nrow carries VAT and Total cells follows SodiumHQ.DTOs.DocumentTemplate.ProposalCosts.ShowVat, as the\nheader does."
          }
        },
        "additionalProperties": false,
        "description": "A billing-frequency section of the proposal costs table (one heading + table per group)."
      },
      "ProposalCostRow": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name including any \" (setup fee)\" suffix. The pricing tier suffix and the\nper-unit breakdown (quantity × rate) are not part of the name — the content block\ncomposes them from PricingTierName and UnitQuantityDisplay/UnitRate/UnitLabel, so\npractices can drop either by editing the block.",
            "nullable": true
          },
          "pricingTierName": {
            "type": "string",
            "description": "The name of the client's pricing tier for tiered services, rendered as a\n\" (TierName)\" suffix by the content block. Null when the service has no tier.",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "description": "The amount charged per billing period, excluding VAT (rate × quantity for per-unit\nservices). Zero for open-ended per-unit rows.",
            "format": "double"
          },
          "showPriceAsNa": {
            "type": "boolean",
            "description": "True when the price cell should render \"N/A\" — a fixed-basis standalone service with\nno price."
          },
          "isOpenEnded": {
            "type": "boolean",
            "description": "True for per-unit services with an unknown quantity: the price cell shows the rate and\nunit label, the VAT and Total cells stay empty, and the row contributes nothing to totals."
          },
          "unitQuantityDisplay": {
            "type": "string",
            "description": "The per-period quantity as displayed (trailing zeros trimmed, e.g. \"12\" or \"2.5\").\nNull for fixed-basis rows and open-ended rows — when set, the name gains a\n\"— {qty} × {rate} {label}\" breakdown.",
            "nullable": true
          },
          "unitRate": {
            "type": "number",
            "description": "The effective rate per unit for non-fixed pricing bases.",
            "format": "double"
          },
          "unitLabel": {
            "type": "string",
            "description": "Unit label for non-fixed pricing bases: \"per hour\", \"per day\" or \"per {unit name}\".\nEmpty for fixed-basis rows.",
            "nullable": true
          },
          "isEstimated": {
            "type": "boolean",
            "description": "True when the billed quantity is expected to vary per period — the unit breakdown is\nsuffixed with \"(estimated)\". Only set when a quantity is known."
          },
          "isCatchUp": {
            "type": "boolean",
            "description": "True for a catch-up fee row (story 2109), which only ever appears in Costs.CatchUp.Rows. Its\nname already carries the label, the backlog window and the instalment wording; the fields\nbelow let a template render them apart."
          },
          "catchUpLabel": {
            "type": "string",
            "description": "The practice's catch-up fee label, as configured. Null unless IsCatchUp.",
            "nullable": true
          },
          "catchUpMonths": {
            "type": "number",
            "description": "Months of backlog the fee covers. Null unless IsCatchUp.",
            "format": "double",
            "nullable": true
          },
          "catchUpInstalments": {
            "type": "integer",
            "description": "How many invoices the fee is spread over (1 = a single payment). Null unless IsCatchUp.",
            "format": "int32",
            "nullable": true
          },
          "catchUpInstalmentAmount": {
            "type": "number",
            "description": "The amount of each instalment but the last (the last absorbs the rounding remainder), or the\nwhole fee for a single payment. Null unless IsCatchUp.",
            "format": "double",
            "nullable": true
          },
          "vatAmount": {
            "type": "number",
            "description": "VAT on the row amount. Packages use the highest rate among their member services.",
            "format": "double"
          },
          "lineTotal": {
            "type": "number",
            "description": "Amount + VatAmount.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "A single line of the proposal costs table: a package, a standalone service, or a setup fee."
      },
      "ProposalCosts": {
        "type": "object",
        "properties": {
          "showVat": {
            "type": "boolean",
            "description": "True when the practice is VAT registered — the table renders the VAT and Total columns."
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProposalCostGroup"
            },
            "description": "One group per billing frequency, ordered Monthly, Quarterly, Annual, One-off.\nFrequencies with no rows are omitted.",
            "nullable": true
          },
          "catchUp": {
            "$ref": "#/components/schemas/ProposalCatchUpCosts"
          }
        },
        "additionalProperties": false,
        "description": "Structured pricing data for the proposal costs table, computed server-side from the\nclient's live billable services. Rendered by the Liquid table in the 'proposal_costs'\ncontent block. Usage in templates: {% for group in Costs.Groups %} ... {% endfor %}"
      },
      "ProposalSource": {
        "enum": [
          "Sodium",
          "Socket"
        ],
        "type": "string",
        "example": "Sodium"
      },
      "ProviderType": {
        "enum": [
          "Smtp",
          "SendGrid",
          "Microsoft365",
          "Google"
        ],
        "type": "string",
        "description": "Represents the type of email provider",
        "example": "Smtp"
      },
      "PurchaseFilingCreditsRequest": {
        "required": [
          "requestId"
        ],
        "type": "object",
        "properties": {
          "blocks": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "Blocks to buy, 1 to the pricing's MaxBlocksPerPurchase.",
            "format": "int32"
          },
          "requestId": {
            "type": "string",
            "description": "Made once per purchase (when the buy dialog opens): sending it again returns the first purchase and buys nothing.",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "Buys blocks of filing credits at Sodium's block price. Needs a Direct Debit (409 billing_mandate_required)."
      },
      "PurchaseMessagingCreditsRequest": {
        "required": [
          "requestId"
        ],
        "type": "object",
        "properties": {
          "blocks": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "Blocks to buy, 1 to the prices' MaxBlocksPerPurchase",
            "format": "int32"
          },
          "requestId": {
            "type": "string",
            "description": "Made once per purchase (when the buy dialog opens): sending it again returns the first purchase and buys nothing",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "Buys blocks of messaging credits at the practice's block price"
      },
      "QahcGains": {
        "type": "object",
        "properties": {
          "gainsFromQahcBeforeLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "lossesFromQahc": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "QualifyingLoanInterest": {
        "type": "object",
        "properties": {
          "customerReference": {
            "type": "string",
            "nullable": true
          },
          "lenderName": {
            "type": "string",
            "nullable": true
          },
          "reliefClaimed": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ReauthoriseConnectionRequest": {
        "type": "object",
        "properties": {
          "redirectUrl": {
            "maxLength": 400,
            "type": "string",
            "description": "Where to send the browser once the platform has redirected back. A literal `[code]` in\nthe URL is replaced with the connection's code — which is unchanged by a reauthorisation.",
            "nullable": true
          },
          "apiKey": {
            "maxLength": 500,
            "type": "string",
            "description": "The fresh API key, for platforms that connect with one instead of a sign-in flow. Ignored on\nOAuth platforms; required when reconnecting an API-key platform.",
            "nullable": true
          },
          "useExtendedScopes": {
            "type": "boolean",
            "description": "The access level for the new grant, where the platform offers extended scopes. Omit to keep\nthe level the connection already has.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Starts a fresh sign-in for a connection the practice already has."
      },
      "ReconnectOAuthRequest": {
        "required": [
          "returnUrl"
        ],
        "type": "object",
        "properties": {
          "returnUrl": {
            "minLength": 1,
            "type": "string",
            "description": "URL to redirect the user back to after completing the OAuth flow"
          }
        },
        "additionalProperties": false,
        "description": "Request to initiate OAuth reconnection for an expired or scope-upgraded configuration"
      },
      "ReconnectOAuthResponse": {
        "type": "object",
        "properties": {
          "authorisationUrl": {
            "type": "string",
            "description": "The OAuth authorisation URL to redirect the user to",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response containing the OAuth authorisation URL for reconnecting a configuration"
      },
      "RecurrenceConfigDto": {
        "type": "object",
        "properties": {
          "every": {
            "type": "integer",
            "description": "Interval value (e.g., 1 for every month, 2 for every 2 months). Required unless Sequence is\nsupplied; omitted from responses when the schedule runs on a Sequence.",
            "format": "int32",
            "nullable": true
          },
          "unit": {
            "$ref": "#/components/schemas/RecurrenceUnit"
          },
          "inMonths": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MonthFlags"
            },
            "description": "Which months to run in. Only valid when Unit is Year.\nExample: [\"January\", \"April\", \"July\", \"October\"] for quarterly",
            "nullable": true
          },
          "weekDaysOnly": {
            "type": "boolean",
            "description": "If true, skip weekends for daily patterns. Only valid when Unit is Day."
          },
          "sequence": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RelativeIntervalDto"
            },
            "description": "Repeating variable-length cycle: the driving date advances by each period in order and wraps\nback to the first (e.g. [4 Weeks, 4 Weeks, 5 Weeks] for a hospitality 4-4-5 cycle). When\nsupplied, replaces Every/Unit entirely. The driving side (per Basis: Start,\nDue, or Statutory) must set Type=Sequence and carry its SequenceSeedDate - the first\noccurrence of that date.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for how often a recurring task repeats."
      },
      "RecurrenceUnit": {
        "enum": [
          "Day",
          "Week",
          "Month",
          "Year"
        ],
        "type": "string",
        "example": "Day"
      },
      "RecurringTaskItemDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete each generated task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate."
          },
          "assignedUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "billableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "sortOrder": {
            "type": "integer",
            "description": "Sort order for displaying recurring tasks.",
            "format": "int32",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this recurring task is active and will generate new tasks."
          },
          "hasCustomSchedules": {
            "type": "boolean",
            "description": "Whether any non-default schedules exist for this task. Maintained automatically as\nschedules are created and deleted - not user-settable."
          },
          "isDefaultSchedule": {
            "type": "boolean",
            "description": "Whether Schedule is the task's default. Only false when the list is filtered by client and\nthat client is linked to a custom schedule - Schedule then carries the custom values."
          },
          "isForServiceClients": {
            "type": "boolean",
            "description": "Only set when the list is filtered by service: true when the task runs for that service's\nclients, false when it is listed only because it is assigned to the service's manager,\npreparer or reviewer. Null on every other read.",
            "nullable": true
          },
          "customSchedule": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "schedule": {
            "$ref": "#/components/schemas/ScheduleConfigDto"
          },
          "process": {
            "$ref": "#/components/schemas/ProcessConfigDto"
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "category": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "clientAssociationType": {
            "$ref": "#/components/schemas/ClientAssociationType"
          },
          "vatReportingPeriod": {
            "$ref": "#/components/schemas/VatReportingPeriod"
          },
          "nextRunDate": {
            "type": "string",
            "description": "The next date this recurring task should be created (for display purposes)",
            "format": "date-time",
            "nullable": true
          },
          "taskNameTemplate": {
            "type": "string",
            "description": "Optional template for naming tasks created from this recurring task.\nSupports {{ token }} placeholders (e.g. \"VAT Return - {{ ClientName }} - {{ Quarter }} {{ Year }}\").\nWhen null or empty, tasks use the recurring task's Name.\nAvailable tokens can be retrieved from the GET /metadata/task-name-tokens endpoint.\nUnrecognised tokens are left as-is in generated task names.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for recurring task templates, exposing only codes and enums."
      },
      "RecurringTaskItemDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecurringTaskItemDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "RecurringTaskItemSortField": {
        "enum": [
          "Name",
          "NextRunDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "RecurringTaskOccurrenceDto": {
        "type": "object",
        "properties": {
          "occurrenceDate": {
            "type": "string",
            "description": "The occurrence's date as the schedule produced it - the task's Start before any manual edit.\nIdentifies the occurrence across creation and deletion.",
            "format": "date"
          },
          "status": {
            "$ref": "#/components/schemas/RecurringTaskOccurrenceStatus"
          },
          "startDate": {
            "type": "string",
            "description": "The task's start date. For a created task this is its current start date, which may have been\nedited away from SodiumHQ.DTOs.TaskItems.RecurringTaskOccurrenceDto.OccurrenceDate. Null for a deleted occurrence.",
            "format": "date",
            "nullable": true
          },
          "dueDate": {
            "type": "string",
            "description": "The task's due date. Null for a deleted occurrence.",
            "format": "date",
            "nullable": true
          },
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "taskStatus": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "deletedBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "deletedDate": {
            "type": "string",
            "description": "When the occurrence was deleted (UTC). Only set for a deleted occurrence.",
            "format": "date-time",
            "nullable": true
          },
          "restoredBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "restoredDate": {
            "type": "string",
            "description": "When the occurrence was restored (UTC). Set alongside SodiumHQ.DTOs.TaskItems.RecurringTaskOccurrenceDto.RestoredBy.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One occurrence of a recurring task for one client: a date the schedule produces (or produced),\nand what happened to it - still to be created, created as a task, or deleted."
      },
      "RecurringTaskOccurrenceDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecurringTaskOccurrenceDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "RecurringTaskOccurrenceStatus": {
        "enum": [
          "Projected",
          "Created",
          "Deleted"
        ],
        "type": "string",
        "example": "Projected"
      },
      "RecurringTaskScheduleDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier of the schedule.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Optional user label; the UI otherwise renders the schedule phrase from the fields.",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether this is the task's default schedule: the one clients without a link run on.\nNot deletable and holds no explicit clients."
          },
          "recurringTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "schedule": {
            "$ref": "#/components/schemas/ScheduleConfigDto"
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Clients linked to this schedule, ordered by name. The list endpoint returns the first few\n(see TotalClients for the real count); the single-schedule endpoint returns all of them.\nAlways empty for the default schedule.",
            "nullable": true
          },
          "totalClients": {
            "type": "integer",
            "description": "Total number of clients linked to this schedule.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A schedule a recurring task runs on. Every task has one default schedule (its own dates) plus\nany number of custom schedules with clients linked to them; a schedule with no clients is\nlegal (parked for later use)."
      },
      "RecurringTaskScheduleDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecurringTaskScheduleDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "RecurringTaskScheduleOccurrencePreviewDto": {
        "type": "object",
        "properties": {
          "startDate": {
            "type": "string",
            "format": "date"
          },
          "dueDate": {
            "type": "string",
            "format": "date"
          },
          "statutoryDate": {
            "type": "string",
            "description": "Null when the schedule has no statutory date.",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The dates one previewed occurrence lands on, after holiday adjustments."
      },
      "RecurringTaskSchedulePreviewDto": {
        "type": "object",
        "properties": {
          "variesByClient": {
            "type": "boolean",
            "description": "True when the schedule uses a client date, so its dates differ from client to client and no\noccurrences are returned."
          },
          "occurrences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecurringTaskScheduleOccurrencePreviewDto"
            },
            "description": "The next occurrences, in date order.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What an unsaved schedule would produce. No occurrences and VariesByClient false means the\nschedule is not complete enough to work out yet."
      },
      "RecurringTaskScheduleSortField": {
        "enum": [
          "ClientCount",
          "Name"
        ],
        "type": "string",
        "example": "ClientCount"
      },
      "RedeemDiscountCodeRequest": {
        "required": [
          "code"
        ],
        "type": "object",
        "properties": {
          "code": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The discount code to redeem (e.g. \"LAUNCH50\")."
          }
        },
        "additionalProperties": false,
        "description": "Request to redeem a discount code for a tenant's subscription."
      },
      "RegisterMtdForeignPropertyRequest": {
        "required": [
          "countryCode",
          "propertyName"
        ],
        "type": "object",
        "properties": {
          "countryCode": {
            "maxLength": 3,
            "minLength": 3,
            "type": "string",
            "description": "ISO 3166-1 alpha-3 code for the country the property is in, e.g. \"FRA\"."
          },
          "propertyName": {
            "maxLength": 105,
            "minLength": 1,
            "type": "string",
            "description": "A name for the property. Must be unique among the client's properties in that country,\nignoring case and surrounding spaces."
          },
          "endDate": {
            "type": "string",
            "description": "When income stopped being received from the property, if it already has. Must be paired with\nSodium.HmrcMtd.Product.Contracts.Dtos.RegisterMtdForeignPropertyRequest.EndReason.",
            "format": "date",
            "nullable": true
          },
          "endReason": {
            "$ref": "#/components/schemas/ForeignPropertyEndReason"
          }
        },
        "additionalProperties": false,
        "description": "Registers a foreign property with HMRC so figures can be filed against it (2026-27 onwards).\nHMRC issue the identifier.\n            \nNot idempotent: each registration creates a new property, so a repeated request leaves the\nclient with two identical lets and no way to tell which one the figures belong to."
      },
      "RelativeIntervalDto": {
        "type": "object",
        "properties": {
          "value": {
            "type": "integer",
            "description": "Numeric value for the interval.",
            "format": "int32",
            "nullable": true
          },
          "unit": {
            "$ref": "#/components/schemas/RecurrenceUnit"
          }
        },
        "additionalProperties": false,
        "description": "Numeric interval (value + unit) used by the Start/Due date configs to express a relative\noffset, e.g. \"10 days after Start\". Replaces the old flat IntervalValue/IntervalUnit pairs."
      },
      "ReliefAmount": {
        "type": "object",
        "properties": {
          "customerReference": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ReliefClaim": {
        "type": "object",
        "properties": {
          "customerReference": {
            "type": "string",
            "nullable": true
          },
          "reliefClaimed": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "RenameMtdSavingsAccountRequest": {
        "required": [
          "accountName"
        ],
        "type": "object",
        "properties": {
          "accountName": {
            "maxLength": 32,
            "minLength": 1,
            "type": "string",
            "description": "The account's new display name. Must still be unique for the client at HMRC."
          }
        },
        "additionalProperties": false,
        "description": "Renames a UK savings account at HMRC. The account keeps its identifier and every year's\ninterest reported against it — only the name changes."
      },
      "RenderContentBlockEmailRequest": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client the email is about. Without one, only practice and date tokens are completed.",
            "nullable": true
          },
          "toEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The To addresses in order. The first that belongs to a contact is who the {{ Contact }} tokens describe.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a one-off email started from a content block knows about who it is for."
      },
      "RenderContentBlockRequest": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/TemplateVariables"
          },
          "includeEmailBranding": {
            "type": "boolean",
            "description": "When true, wraps the rendered body with the tenant's email header, footer, and design theme\nfrom Email Settings. Use for email previews."
          }
        },
        "additionalProperties": false,
        "description": "Request to render a content block's body HTML with template variables.\nOptionally wraps the rendered body with the tenant's email header, footer, and design theme."
      },
      "RenderDocumentTemplateRequest": {
        "type": "object",
        "properties": {
          "designThemeCode": {
            "type": "string",
            "description": "Optional design theme code to override the template's default theme.\nPriority: Request theme > Template default > Tenant default",
            "nullable": true
          },
          "data": {
            "$ref": "#/components/schemas/TemplateVariables"
          },
          "clientCode": {
            "type": "string",
            "description": "Code of the client whose services the pricing table is built from.\nRequired when ServiceCodes is supplied.",
            "nullable": true
          },
          "serviceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the client billable services to include in the proposal costs table.\nWhen supplied, the server computes the Costs template data from these live services\n(prices, VAT, setup fees) so the 'proposal_costs' content block can render the table.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to render a document template with dynamic data.\nThe template will be processed with the provided data to generate final HTML output."
      },
      "RenderMessagingTemplateRequest": {
        "type": "object",
        "properties": {
          "clientCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The client the message goes from. With `to`, a contact of the client holding that number fills\nthe Contact tokens.",
            "nullable": true
          },
          "conversationCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The conversation the message goes on: its client and contact fill the tokens (an unmatched one fills\nonly the practice and date tokens). Takes precedence over `clientCode`.",
            "nullable": true
          },
          "to": {
            "maxLength": 30,
            "minLength": 0,
            "type": "string",
            "description": "The recipient's number, with `clientCode`",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Who to render a practice text template for: a client's number (`clientCode` + `to`), a\nconversation, or nobody (practice and date tokens only)"
      },
      "RenderTemplateStringRequest": {
        "required": [
          "template"
        ],
        "type": "object",
        "properties": {
          "template": {
            "minLength": 1,
            "type": "string",
            "description": "The Liquid template string to render (e.g. a subject line like \"Professional Clearance for {{ Client.Name }}\")"
          },
          "data": {
            "$ref": "#/components/schemas/TemplateVariables"
          }
        },
        "additionalProperties": false,
        "description": "Request to render an arbitrary Liquid template string with the provided variables.\nUse for rendering subject lines or other template strings outside of content blocks."
      },
      "RenderedContentBlockEmailDto": {
        "type": "object",
        "properties": {
          "subject": {
            "type": "string",
            "nullable": true
          },
          "bodyHtml": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A content block's subject and body with tokens completed, ready to edit in the email composer."
      },
      "ReopenDataFormRequestRequest": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "A message explaining what the client got wrong and needs to change, included in the\nnotification email. If not specified, the message from the original request is reused.",
            "nullable": true
          },
          "recipients": {
            "$ref": "#/components/schemas/EmailRecipientConfig"
          },
          "stopChasingOthers": {
            "type": "boolean",
            "description": "Whether these recipients replace the request's recipients. False (the default) adds to them:\neveryone the form already went to keeps their link and keeps being chased. True makes these\nthe only recipients: anyone else stops being chased and their links stop working."
          }
        },
        "additionalProperties": false,
        "description": "DTO for sending an already-submitted form back to the client to complete again"
      },
      "ReorderDashboardLinksRequest": {
        "required": [
          "codes",
          "scope"
        ],
        "type": "object",
        "properties": {
          "scope": {
            "$ref": "#/components/schemas/DashboardLinkScope"
          },
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The new order. Each link's sort order becomes its 0-based position in this list."
          }
        },
        "additionalProperties": false,
        "description": "Request to reorder one dashboard list"
      },
      "ReorderEmailTriageHeaderWidgetsRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The complete new order. Each widget's sort order becomes its 0-based position in this list."
          }
        },
        "additionalProperties": false,
        "description": "Request to reorder the practice's email page header widgets"
      },
      "ReorderEmailTriageStatusesRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The complete new order. Each status's sort order becomes its 0-based position in this list."
          }
        },
        "additionalProperties": false,
        "description": "Request to reorder the tenant's email triage statuses"
      },
      "ReorderProfessionalClearanceRequestItemsRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The complete new order. Each item's sort order becomes its 0-based position in this list."
          }
        },
        "additionalProperties": false,
        "description": "Request to reorder professional clearance request items"
      },
      "ReplyEmailResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the reply was sent successfully"
          },
          "errorMessage": {
            "type": "string",
            "description": "Error message if the reply failed",
            "nullable": true
          },
          "reconnectRequired": {
            "type": "boolean",
            "description": "Whether the user needs to reconnect their mailbox"
          }
        },
        "additionalProperties": false,
        "description": "Response after replying to a mailbox email"
      },
      "ReplyMailboxEmailRequest": {
        "required": [
          "htmlBody"
        ],
        "type": "object",
        "properties": {
          "plainTextBody": {
            "type": "string",
            "description": "Plain text body (optional fallback)",
            "nullable": true
          },
          "replyAll": {
            "type": "boolean",
            "description": "Whether to reply to all recipients (default: false = reply to sender only)"
          },
          "toRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "Override To recipients. Null = use provider default (original sender for reply, all for reply-all).\nEmpty list = explicitly no To recipients.",
            "nullable": true
          },
          "ccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "Override CC recipients. Null = use provider default.\nEmpty list = explicitly no CC recipients (useful for removing CC on reply-all).",
            "nullable": true
          },
          "bccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "BCC recipients. Null or empty = no BCC (providers never auto-populate BCC).",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAttachmentDto"
            },
            "description": "Attachments to include in the reply. Null or empty = no attachments.",
            "nullable": true
          },
          "quoteOriginal": {
            "type": "boolean",
            "description": "Whether a sent reply carries the email it answers below the caller's text (\"On ... wrote:\" and\nthe original, quoted), as Outlook and Gmail do. Off by default: the reply is the caller's text\nalone. A reply draft is never quoted."
          },
          "htmlBody": {
            "minLength": 1,
            "type": "string",
            "description": "HTML body of the reply. Redeclared from the email service contract so it is cleaned as the request is read."
          },
          "practiceDocumentCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of practice documents (tenant document library) to attach. Resolved to file\ncontent server-side, so the browser never round-trips the document bytes.",
            "nullable": true
          },
          "scheduledAt": {
            "type": "string",
            "description": "When set, the reply is not sent now: a scheduled send is created and dispatched at this\nUTC instant. Must be in the future. Omit to send immediately.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to reply to a mailbox message: the reply draft's content (body, recipients, practice\ndocument attachments resolved server-side by code), sent now or at a scheduled time."
      },
      "ReportGroupKind": {
        "enum": [
          "Service",
          "Client",
          "User",
          "Team",
          "StepType",
          "AgeBucket",
          "Status",
          "CurrentStep",
          "None",
          "Month",
          "Unassigned",
          "Task",
          "WorkflowStep",
          "Stage"
        ],
        "type": "string",
        "example": "Service"
      },
      "RequestClientApprovalForDocumentsRequest": {
        "required": [
          "documentCodes"
        ],
        "type": "object",
        "properties": {
          "documentCodes": {
            "maxItems": 50,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the documents to send for approval. Duplicates are ignored."
          },
          "mode": {
            "$ref": "#/components/schemas/DocumentApprovalRequestMode"
          },
          "recipientEmails": {
            "type": "string",
            "description": "Comma-separated email addresses of recipients to send the approval request to",
            "nullable": true
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for the chase frequency in days. If not specified, the tenant default is used\nfor portal approvals; e-signature approvals default to no chasing (the signing platform\nsends its own reminders) unless a value is given. 0 switches chasing off for either method.",
            "format": "int32",
            "nullable": true
          },
          "approvalMethod": {
            "$ref": "#/components/schemas/DocumentApprovalMethod"
          },
          "prepareOnPlatform": {
            "type": "boolean",
            "description": "E-signature only: create the bundle on the signing platform as a draft instead of sending\nit, so the practice can place the signature fields on the document in the platform's own\neditor and send it from there. Nothing reaches the client until they do. Ignored for\nportal approvals, which have no platform to prepare anything on."
          },
          "message": {
            "type": "string",
            "description": "Optional message for the client, as HTML. Shown in the approval email in place of the\ndocuments' descriptions, for this request only. Ignored for e-signature approvals.",
            "nullable": true
          },
          "composedEmail": {
            "$ref": "#/components/schemas/ComposedEmail"
          },
          "scheduledAt": {
            "type": "string",
            "description": "When set, approval is not requested now: no batch is created and the documents are left\nuntouched until a scheduled send dispatches the request at this UTC instant. Must be in\nthe future. Omit to request approval immediately.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Sends one or more documents to a client for approval, either as a single batch decided\ntogether or as a separate approval request per document."
      },
      "RequestClientApprovalForDocumentsResultDto": {
        "type": "object",
        "properties": {
          "batchCode": {
            "type": "string",
            "description": "The code of the approval batch that was created. Null in Individual mode.",
            "nullable": true
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentActionResultDto"
            },
            "description": "One entry per document code submitted, in the order they were sent.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of a multi-document approval request. In Individual mode each document is sent\nindependently, so the results can contain a mix of successes and failures; in Batch mode the\nrequest is all-or-nothing and every result succeeds."
      },
      "RequestItemTokens": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer",
            "description": "How many items the request has",
            "format": "int32"
          },
          "waitingCount": {
            "type": "integer",
            "description": "How many items are waiting for the client to answer",
            "format": "int32"
          },
          "added": {
            "type": "boolean",
            "description": "True when the email is telling the client that items were added to a request they already have"
          }
        },
        "additionalProperties": false,
        "description": "An information request's items, for the email that sends the request: null when the request has no\nitems, so a template tests for them with {% if Items %}.\nUsage in templates: {{ Items.Count }}, {{ Items.WaitingCount }}, {% if Items.Added %}"
      },
      "RequestRecipientsDto": {
        "type": "object",
        "properties": {
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The recipients' email addresses.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Who an outstanding client request currently counts as its recipients: the addresses it was\nsent to and has not since been withdrawn from. These are the people its chases go to."
      },
      "RequestSummaryDto": {
        "type": "object",
        "properties": {
          "readyToSend": {
            "type": "integer",
            "description": "Manual-mode workflow steps assigned to the calling user and ready to send.\nScoped to the caller to match the Ready to Send tab, which defaults to the same.",
            "format": "int32",
            "nullable": true
          },
          "scheduled": {
            "type": "integer",
            "description": "Pending scheduled sends (Scheduled and Failed), scoped to the send types the caller can manage",
            "format": "int32",
            "nullable": true
          },
          "formsAwaitingResponse": {
            "type": "integer",
            "description": "Data form requests sent and not yet responded to",
            "format": "int32",
            "nullable": true
          },
          "documentApprovalsPending": {
            "type": "integer",
            "description": "Documents sent for client approval and still awaiting a decision",
            "format": "int32",
            "nullable": true
          },
          "documentRequestsOpen": {
            "type": "integer",
            "description": "Document requests still open with the client",
            "format": "int32",
            "nullable": true
          },
          "documentRequestsSubmitted": {
            "type": "integer",
            "description": "Document requests the client has submitted, waiting on the practice to accept or reject",
            "format": "int32",
            "nullable": true
          },
          "documentRequestsToReview": {
            "type": "integer",
            "description": "Document requests with something for the practice to look at: submitted as a whole, or with\nanswered items waiting to be resolved or sent back (a request with items can be both still with\nthe client and waiting for review)",
            "format": "int32",
            "nullable": true
          },
          "confirmationsOpen": {
            "type": "integer",
            "description": "Client confirmations sent and not yet confirmed",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Outstanding counts for each kind of item on the Requests page, in one call.\n\nEvery count is null when the caller's role cannot read that area, rather than zero:\nzero means \"nothing outstanding\", null means \"not yours to see\". Callers rendering\nthese as tiles should hide a null rather than show a dash."
      },
      "ResendDataFormRequestRequest": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "A message explaining what the client needs to do, included in the notification email.\nIf not specified, the original message is used.",
            "nullable": true
          },
          "recipients": {
            "$ref": "#/components/schemas/EmailRecipientConfig"
          },
          "stopChasingOthers": {
            "type": "boolean",
            "description": "Whether these recipients replace the request's recipients. False (the default) adds to them:\neveryone the form already went to keeps their link and keeps being chased. True makes these\nthe only recipients: anyone else stops being chased and their links stop working."
          }
        },
        "additionalProperties": false,
        "description": "DTO for resending the notification email for a form request"
      },
      "ResendRequestRequest": {
        "required": [
          "recipientEmails"
        ],
        "type": "object",
        "properties": {
          "recipientEmails": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The email addresses to send to. Each gets its own fresh link. At least one is required."
          },
          "stopChasingOthers": {
            "type": "boolean",
            "description": "Whether these addresses replace the request's recipients. False (the default) adds to them:\neveryone the request already went to keeps their link and keeps being chased. True makes\nthese the only recipients: anyone else stops being chased and their links stop working."
          }
        },
        "additionalProperties": false,
        "description": "Request to resend an outstanding client request (a document request, an approval request or a\nclient confirmation) to a chosen set of addresses."
      },
      "ResendVerificationResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the resend was successful"
          },
          "message": {
            "type": "string",
            "description": "A message describing the result",
            "nullable": true
          },
          "errorCode": {
            "type": "string",
            "description": "Error code for client handling",
            "nullable": true
          },
          "userEmail": {
            "type": "string",
            "description": "The email address the verification was sent to (only included on success)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for resending verification email"
      },
      "ResetBudgetOverridesRequest": {
        "required": [
          "clientServices"
        ],
        "type": "object",
        "properties": {
          "clientServices": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientServiceRefDto"
            },
            "description": "The client services to reset"
          }
        },
        "additionalProperties": false,
        "description": "Clears the own figures of one measure on the given client services; modes and percentages stay"
      },
      "ResetBudgetOverridesResultDto": {
        "type": "object",
        "properties": {
          "resetCount": {
            "type": "integer",
            "description": "How many client services had own figures cleared",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The outcome of a reset"
      },
      "ResidentialDisposal": {
        "type": "object",
        "properties": {
          "numberOfDisposals": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "customerReference": {
            "type": "string",
            "nullable": true
          },
          "disposalDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "completionDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "disposalProceeds": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "acquisitionDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "acquisitionAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "improvementCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "additionalCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "prfAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherReliefAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsWithBadr": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsBeforeLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "lossesFromThisYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "claimOrElectionCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "amountOfNetGain": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountOfNetLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ResolvedTimeEntryRatesDto": {
        "type": "object",
        "properties": {
          "hourlyRate": {
            "type": "number",
            "description": "Charge-out rate per hour, applied if the entry is billable. Null when no rule sets one.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The charge-out rate a time entry would get if logged now with the given team member, date,\ntask and service — what the time entry form shows as the default."
      },
      "RetirementSchemeBenefit": {
        "type": "object",
        "properties": {
          "amount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "exemptAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxTakenOffInEmployment": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ReuseMessagingNumberApplicationRequest": {
        "type": "object",
        "properties": {
          "applicationId": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "The earlier application, as `reusable.applicationId` gives it",
            "format": "int32"
          },
          "requestedPhoneNumber": {
            "maxLength": 30,
            "minLength": 0,
            "type": "string",
            "description": "The number chosen from the available numbers, E.164; null for the first available",
            "nullable": true
          },
          "agreedToCosts": {
            "type": "boolean",
            "description": "The applicant agrees to the number's monthly price and to paying for the credits the practice buys, as the page\nshowed them. Must be true."
          }
        },
        "additionalProperties": false,
        "description": "Gets a number with an earlier application's approved details (the reusable one the number application read offers)"
      },
      "RevenueRangeDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this revenue range",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the revenue range (e.g., \"£30k - £70k\")",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying revenue ranges",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A revenue band used for tiered service pricing"
      },
      "RevenueRangeDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RevenueRangeDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "RevenueRangeSortField": {
        "enum": [
          "SortOrder",
          "Name"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "ReviewClientDocumentRequest": {
        "type": "object",
        "properties": {
          "reviewStatus": {
            "$ref": "#/components/schemas/ReviewStatus"
          }
        },
        "additionalProperties": false,
        "description": "Request to approve or reject a client-uploaded document"
      },
      "ReviewDataFormAnswerRequest": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "boolean",
            "description": "True to accept and apply the value, false to reject."
          },
          "value": {
            "type": "string",
            "description": "Optional edited value to use instead of the original answer when accepting.\nIgnored when rejecting.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request body for reviewing (accepting/rejecting) a single form answer."
      },
      "ReviewDocumentRequestItemsRequest": {
        "required": [
          "decisions"
        ],
        "type": "object",
        "properties": {
          "decisions": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestItemDecision"
            },
            "description": "One decision per item"
          },
          "notifyClient": {
            "type": "boolean",
            "description": "Whether to email the client the items sent back with their notes. Defaults to yes when anything\nis sent back.",
            "nullable": true
          },
          "makeDocumentsAvailable": {
            "type": "boolean",
            "description": "When these decisions resolve the last item, whether to publish the client's files to their\nDocuments, as accepting a whole request can"
          },
          "portalFolderPath": {
            "maxLength": 2000,
            "type": "string",
            "description": "Optional portal folder path for published files",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The practice's decisions on items, applied together"
      },
      "ReviewDocumentRequestResponseRequest": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "boolean",
            "description": "Whether to accept the submission. If false, NextAction determines what happens."
          },
          "reviewNote": {
            "type": "string",
            "description": "Note from the reviewer explaining the decision",
            "nullable": true
          },
          "nextAction": {
            "$ref": "#/components/schemas/DocumentRequestRejectAction"
          },
          "makeDocumentsAvailable": {
            "type": "boolean",
            "description": "When accepting, whether to publish the request's documents to the main Documents list.\nDefaults to true. Only used when Accepted is true."
          },
          "portalFolderPath": {
            "type": "string",
            "description": "When publishing, the portal folder path where the documents should appear.\nNull or omitted means the client root. Only used when MakeDocumentsAvailable is true.\nFormat: \"/\" separated folder names, e.g. \"Tax Returns/2026\".",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for reviewing (accepting or rejecting) a document request response"
      },
      "ReviewLoggedTimeBillingMode": {
        "enum": [
          "Optional",
          "Required",
          "Off"
        ],
        "type": "string",
        "example": "Optional"
      },
      "ReviewLoggedTimeDefaultsDto": {
        "type": "object",
        "properties": {
          "lineDescription": {
            "type": "string",
            "description": "The billing line description, tokens rendered. Null when the step sets none.",
            "nullable": true
          },
          "accountingCode": {
            "type": "string",
            "description": "The accounting (nominal) code. Null when the step sets none.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a Review & Bill Time step pre-fills when its time is billed, with the line description's\ntokens rendered for the step's task and client."
      },
      "ReviewLoggedTimeScope": {
        "enum": [
          "Task",
          "TaskAndService",
          "Client"
        ],
        "type": "string",
        "example": "Task"
      },
      "ReviewLoggedTimeStepConfigDto": {
        "type": "object",
        "properties": {
          "timeScope": {
            "$ref": "#/components/schemas/ReviewLoggedTimeScope"
          },
          "includeNonBillable": {
            "type": "boolean",
            "description": "Also list the task's non-billable time, for reference"
          },
          "billingMode": {
            "$ref": "#/components/schemas/ReviewLoggedTimeBillingMode"
          },
          "lineDescription": {
            "maxLength": 500,
            "type": "string",
            "description": "The billing line description to start from when billing the time. Supports template tokens\n(e.g. {{ Client.Name }}, {{ Task.DueDate }}). Blank uses the billing run's default summary.",
            "nullable": true
          },
          "accountingCode": {
            "maxLength": 20,
            "type": "string",
            "description": "The accounting (nominal) code to start from when billing the time. Blank uses the client's\nbilling settings.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for ReviewLoggedTime workflow steps: which time the reviewer sees. The step\nnever executes; billing and writing time off or on use the time-entry endpoints, and the\nreviewer marks the step complete."
      },
      "ReviewStatus": {
        "enum": [
          "Approved",
          "PendingReview",
          "Rejected"
        ],
        "type": "string",
        "example": "Approved"
      },
      "RoleDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code identifying this role",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the role",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional description of what this role is for",
            "nullable": true
          },
          "assignedUserCount": {
            "type": "integer",
            "description": "The number of users currently assigned to this role",
            "format": "int32"
          },
          "permissions": {
            "type": "object",
            "properties": {
              "Tasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Users": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Clients": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Contacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientContacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Reports": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Settings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ApiKeys": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Roles": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ServicePackages": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "RecurringTasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Workflows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ThirdPartyConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ContentBlocks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDetails": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DesignThemes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Templates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Engagements": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CustomFields": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Subscription": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientPortalSettings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DocumentRequests": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Billing": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientEmailRules": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Mailbox": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Teams": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DataForms": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "KanbanBoards": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBilling": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailBroadcasts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeTracking": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Pipelines": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "WorkingPatterns": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalIncomeTax": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalTaxReturn": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooksConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BookkeepingHealth": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CostRates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ProductAccounts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Messaging": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeOff": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailTriage": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "JobBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "OutboundWebhooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeOverrides": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              }
            },
            "additionalProperties": false,
            "description": "The capabilities granted per entity. Each entry lists the granted capabilities individually —\nthere is no implicit hierarchy; an entry containing \"Admin\" grants every capability on that\nentity. Entities granting nothing are omitted.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the role was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the role was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A custom (tenant-defined) role and the capabilities it grants per entity."
      },
      "RoleDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RoleDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "RoleHandover": {
        "required": [
          "role"
        ],
        "type": "object",
        "properties": {
          "role": {
            "$ref": "#/components/schemas/WorkflowStepAssignmentType"
          },
          "clientServiceCode": {
            "type": "string",
            "description": "The client service the role belongs to (its own code). Required for a service role, and only for one.",
            "nullable": true
          },
          "previousUserCode": {
            "type": "string",
            "description": "Who held the role before; null if nobody did. Work still with them, or with nobody, moves.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One role that changed hands."
      },
      "RoleHandoverRequest": {
        "required": [
          "handovers"
        ],
        "type": "object",
        "properties": {
          "handovers": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RoleHandover"
            },
            "description": "The roles that changed. The new holder of each is read from the client or service as saved."
          }
        },
        "additionalProperties": false,
        "description": "Client or service roles that have just changed hands, whose open work should follow the new holder."
      },
      "RoleHandoverResultDto": {
        "type": "object",
        "properties": {
          "role": {
            "$ref": "#/components/schemas/WorkflowStepAssignmentType"
          },
          "clientServiceCode": {
            "type": "string",
            "description": "The client service the role belongs to, for a service role.",
            "nullable": true
          },
          "newUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "taskCount": {
            "type": "integer",
            "description": "Open tasks whose owner comes from this role (through their recurring task) and that move.",
            "format": "int32"
          },
          "stepCount": {
            "type": "integer",
            "description": "Workflow steps, not yet done, assigned from this role that move.",
            "format": "int32"
          },
          "affectedTaskCount": {
            "type": "integer",
            "description": "The distinct open tasks touched, whether the task itself or only some of its steps move.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The open work one role handover moves, or moved."
      },
      "RoleInfo": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The code of the custom role, when Type is Custom. Null for system roles.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the user's role within this tenant",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/RoleType"
          },
          "isOwner": {
            "type": "boolean",
            "description": "Whether the user is the owner of the tenant.\nThis is computed from Tenant.OwnerUserId."
          },
          "isClientManager": {
            "type": "boolean",
            "description": "Whether the user is a client manager within the tenant"
          },
          "isPartner": {
            "type": "boolean",
            "description": "Whether the user is a partner within the tenant"
          },
          "isAssociate": {
            "type": "boolean",
            "description": "Whether the user is an associate within the tenant"
          },
          "isRestrictedToTeamClients": {
            "type": "boolean",
            "description": "Whether the user can only see clients belonging to their teams"
          },
          "isRestrictedToAssignedClients": {
            "type": "boolean",
            "description": "Whether the user can only see clients where they are Manager, Partner, or Associate"
          },
          "isRestrictedToOwnTime": {
            "type": "boolean",
            "description": "Whether the user can only see and edit their own time entries"
          },
          "isPaidForTrackedTime": {
            "type": "boolean",
            "description": "Whether the practice pays this user for their tracked time (contract basis) —\nputs them on the Unpaid Time pay surfaces"
          },
          "teams": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "Teams the user is a member of",
            "nullable": true
          },
          "permissions": {
            "type": "object",
            "properties": {
              "Tasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Users": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Clients": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Contacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientContacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Reports": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Settings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ApiKeys": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Roles": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ServicePackages": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "RecurringTasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Workflows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ThirdPartyConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ContentBlocks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDetails": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DesignThemes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Templates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Engagements": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CustomFields": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Subscription": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientPortalSettings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DocumentRequests": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Billing": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientEmailRules": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Mailbox": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Teams": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DataForms": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "KanbanBoards": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBilling": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailBroadcasts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeTracking": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Pipelines": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "WorkingPatterns": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalIncomeTax": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalTaxReturn": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooksConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BookkeepingHealth": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CostRates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ProductAccounts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Messaging": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeOff": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailTriage": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "JobBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "OutboundWebhooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeOverrides": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              }
            },
            "additionalProperties": false,
            "description": "The capabilities granted for each permissible entity (Clients, Tasks, etc.) within the tenant.\nEach entry lists the granted capabilities individually — there is no implicit hierarchy, so\n\"Delete\" does not imply \"ViewAll\". An entry containing \"Admin\" grants every capability.\nEntities the role grants nothing on are omitted.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Information about a user's role within a tenant, including permissions and special designations"
      },
      "RoleSortField": {
        "enum": [
          "Name",
          "CreatedDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "RoleType": {
        "enum": [
          "System",
          "Custom"
        ],
        "type": "string",
        "example": "System"
      },
      "RunningTimerDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for the timer",
            "nullable": true
          },
          "user": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "startedAt": {
            "type": "string",
            "description": "When the timer was first started (UTC) — the start of its first block",
            "format": "date-time"
          },
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimerBlockDto"
            },
            "description": "The blocks of work accrued as the timer is paused and resumed. The block\nwith no end time is the one currently running; none open means the timer\nis paused. Elapsed working time is the sum of the blocks.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "What the time is being spent on",
            "nullable": true
          },
          "isBillable": {
            "type": "boolean",
            "description": "Whether the logged time will be billable — carried onto the entry when the timer stops"
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "taskItem": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflowStep": {
            "$ref": "#/components/schemas/LinkedWorkflowStepDto"
          },
          "timeEntryCode": {
            "type": "string",
            "description": "The code of the existing time entry the timer adds to when it stops, if any.\nNull means stopping the timer logs a new entry.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The calling user's live timer"
      },
      "SalesPipelineSettingsDto": {
        "type": "object",
        "properties": {
          "isEnabled": {
            "type": "boolean",
            "description": "Whether the Sales Pipeline feature is enabled for this tenant. When off (the default), the\npipeline UI is hidden and no pipeline automations run. When on, Active Prospects are also\nincluded in the tenant's billable client count (affecting subscription tier and pricing)."
          }
        },
        "additionalProperties": false,
        "description": "Tenant-level settings for the Sales Pipeline feature."
      },
      "SaveClientDateDto": {
        "type": "object",
        "properties": {
          "dateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "date": {
            "type": "string",
            "description": "The date value to set for this client date type",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating or updating an important client date.\nUsed to set dates like year-end, accounts due, or VAT return deadlines that drive recurring task generation."
      },
      "SaveConversationCommentRequest": {
        "required": [
          "text"
        ],
        "type": "object",
        "properties": {
          "text": {
            "maxLength": 10000,
            "minLength": 1,
            "type": "string",
            "description": "The comment text"
          }
        },
        "additionalProperties": false,
        "description": "Request to add or edit a comment on an email conversation. Mention someone as\n`@[Name](user-code)`; only people who can read the mailbox are told."
      },
      "SaveConversationSummaryRequest": {
        "type": "object",
        "properties": {
          "text": {
            "maxLength": 10000,
            "type": "string",
            "description": "The summary, plain text; empty to delete it",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to write an email conversation's summary by hand. Empty text deletes the summary."
      },
      "SaveEmailTriageHeaderWidgetRequest": {
        "required": [
          "configJson"
        ],
        "type": "object",
        "properties": {
          "title": {
            "maxLength": 100,
            "type": "string",
            "description": "The widget's heading, at most 100 characters; empty or omitted for a widget without one",
            "nullable": true
          },
          "configJson": {
            "minLength": 1,
            "type": "string",
            "description": "The widget's settings as JSON, in the web app's own shape. Must be valid JSON of at most 8 KB."
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position across the top of the email page",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Request to create or update (a full replacement) an email page header widget"
      },
      "SaveMtdAnnualSubmissionRequest": {
        "required": [
          "incomeSourceType"
        ],
        "type": "object",
        "properties": {
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "selfEmployment": {
            "$ref": "#/components/schemas/SelfEmploymentAnnualSubmission"
          },
          "ukProperty": {
            "$ref": "#/components/schemas/UkPropertyAnnualSubmission"
          },
          "foreignProperty": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignPropertyAnnualEntry"
            },
            "description": "The foreign property values, one entry per let. Required when the income source is a foreign\nproperty business, and must be absent otherwise.\n            \nThe replacement is of the whole list: a let HMRC currently hold and this request omits has\nits annual values removed, so the form must send every let that should stand.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year-end annual submission for one income source and tax year.\n            \nA **full replacement** at HMRC: everything that should survive must be present, because what is\nabsent is cleared. Clearing the whole submission is a delete, not an empty save — the MTD\nservice refuses an all-empty request rather than silently wiping the year."
      },
      "SaveMtdCgtPpdOverridesRequest": {
        "type": "object",
        "properties": {
          "multiplePropertyDisposals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PpdMultiplePropertyDisposal"
            },
            "description": "Overrides for returns covering several disposals: the net gain or loss only.",
            "nullable": true
          },
          "singlePropertyDisposals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PpdSinglePropertyDisposal"
            },
            "description": "Overrides for returns covering one disposal: the figures behind the result.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's overrides to residential property disposals HMRC already hold from their\n'Report and pay Capital Gains Tax on UK property' service. A full replacement of the overrides,\nwhich HMRC accept only after the tax year has ended.\n            \nEach override names the return it replaces by HMRC's submission identifier, so an override can\nonly be made for a disposal HMRC already hold."
      },
      "SaveMtdCgtResidentialDisposalsRequest": {
        "required": [
          "disposals"
        ],
        "type": "object",
        "properties": {
          "disposals": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResidentialDisposal"
            },
            "description": "The disposals. Every one that should survive must be present — the save replaces the list."
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's UK residential property disposals for Self Assessment at HMRC — a full\nreplacement of the list.\n            \nReporting a disposal here does not discharge the in-year property payment-on-account return the\nclient files within 60 days of completion; a disposal can need both."
      },
      "SaveMtdCharitableGivingRequest": {
        "type": "object",
        "properties": {
          "giftAidPayments": {
            "$ref": "#/components/schemas/GiftAidPayments"
          },
          "gifts": {
            "$ref": "#/components/schemas/CharitableGifts"
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's charitable giving reliefs at HMRC — a full replacement of both halves, so send\ngift aid and gifts together whenever both should stand."
      },
      "SaveMtdDirectorshipDividendRequest": {
        "required": [
          "companyDirector"
        ],
        "type": "object",
        "properties": {
          "companyDirector": {
            "type": "boolean",
            "description": "Whether the client is a director of the company. Required by HMRC, and the answer the whole\nresource exists to record — so it is not defaulted."
          },
          "closeCompany": {
            "type": "boolean",
            "description": "Whether the company is a close company.",
            "nullable": true
          },
          "directorshipCeasedDate": {
            "type": "string",
            "description": "The date the directorship ceased, when it ceased in the year.",
            "format": "date",
            "nullable": true
          },
          "companyName": {
            "maxLength": 160,
            "type": "string",
            "description": "The company's name.",
            "nullable": true
          },
          "companyNumber": {
            "maxLength": 20,
            "type": "string",
            "description": "The company's Companies House registration number.",
            "nullable": true
          },
          "shareholding": {
            "maximum": 100,
            "minimum": 0,
            "type": "number",
            "description": "The client's shareholding in the company, as a percentage.",
            "format": "double",
            "nullable": true
          },
          "dividendReceived": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "The dividends received from the company.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the directorship and dividend information for one employment — a full replacement."
      },
      "SaveMtdDividendsIncomeRequest": {
        "type": "object",
        "properties": {
          "foreignDividend": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignDividendItem"
            },
            "description": "Dividends from foreign companies. Each item needs a country code and taxable amount.",
            "nullable": true
          },
          "dividendIncomeReceivedWhilstAbroad": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignDividendItem"
            },
            "description": "Dividend income received whilst abroad.",
            "nullable": true
          },
          "stockDividend": {
            "$ref": "#/components/schemas/DividendGross"
          },
          "redeemableShares": {
            "$ref": "#/components/schemas/DividendGross"
          },
          "bonusIssuesOfSecurities": {
            "$ref": "#/components/schemas/DividendGross"
          },
          "closeCompanyLoansWrittenOff": {
            "$ref": "#/components/schemas/DividendGross"
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's foreign and special dividends at HMRC.\n            \nA <strong>full replacement</strong>: everything that should survive must be present, because\nwhat is absent is cleared. Clearing the year is a delete, not an empty save — an all-empty\nrequest is refused rather than silently wiping what HMRC hold.\n            \nWho is sending it is taken from the authenticated user, never from the request — the stamp is\nevidence of who filed, so it cannot be something a caller supplies."
      },
      "SaveMtdEmploymentFinancialDetailsRequest": {
        "required": [
          "pay"
        ],
        "type": "object",
        "properties": {
          "pay": {
            "$ref": "#/components/schemas/EmploymentPayInput"
          },
          "deductions": {
            "$ref": "#/components/schemas/EmploymentDeductions"
          },
          "benefitsInKind": {
            "$ref": "#/components/schemas/BenefitsInKind"
          },
          "offPayrollWorker": {
            "type": "boolean",
            "description": "Whether the client is an off-payroll worker for this engagement (IR35).",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the financial details for one employment — pay, tax, benefits in kind and deductions — as\na <strong>full replacement</strong> of what HMRC hold from this side.\n            \nThese are the customer-provided figures. Sending them does not overwrite what the employer\nsubmitted: HMRC keep both and the customer figures take precedence for the year, which is why\nclearing them restores the employer's."
      },
      "SaveMtdFigureMappingRequest": {
        "required": [
          "mappingJson",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "Display name for the mapping."
          },
          "mappingJson": {
            "minLength": 1,
            "type": "string",
            "description": "The label→field entries, as JSON owned by the importing form."
          }
        },
        "additionalProperties": false,
        "description": "Saves (or replaces) the remembered mapping for one income source type."
      },
      "SaveMtdForeignReliefsRequest": {
        "type": "object",
        "properties": {
          "foreignTaxCreditRelief": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Foreign tax credit relief claimed.",
            "format": "double",
            "nullable": true
          },
          "foreignIncomeTaxCreditRelief": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignIncomeTaxCreditRelief"
            },
            "description": "Foreign income tax credit relief entries by country. HMRC require a country code, taxable\namount and the employment-lump-sum answer on every entry.",
            "nullable": true
          },
          "foreignTaxForFtcrNotClaimed": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Foreign tax paid for which foreign tax credit relief is not claimed.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's foreign tax reliefs at HMRC — a full replacement."
      },
      "SaveMtdInvestmentReliefsRequest": {
        "type": "object",
        "properties": {
          "vctSubscription": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "description": "Venture capital trust subscriptions.",
            "nullable": true
          },
          "eisSubscription": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "description": "Enterprise investment scheme subscriptions.",
            "nullable": true
          },
          "communityInvestment": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "description": "Community investment tax relief subscriptions.",
            "nullable": true
          },
          "seedEnterpriseInvestment": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "description": "Seed enterprise investment scheme subscriptions.",
            "nullable": true
          },
          "socialEnterpriseInvestment": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvestmentSubscription"
            },
            "description": "Social enterprise investment (SITR) subscriptions. HMRC dropped these from later tax years —\nsending them for a year that no longer defines them is refused by HMRC, not silently ignored.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's investment reliefs at HMRC.\n            \nA <strong>full replacement</strong>: every subscription that should survive must be in the\nrequest, because what is absent is cleared. Clearing the year is a delete, not an empty save."
      },
      "SaveMtdLossesAndClaimsRequest": {
        "type": "object",
        "properties": {
          "claims": {
            "$ref": "#/components/schemas/LossClaims"
          },
          "losses": {
            "$ref": "#/components/schemas/LossesBroughtForward"
          }
        },
        "additionalProperties": false,
        "description": "Creates or amends one income source's losses and claims for a tax year from 2026-27 onwards —\na full replacement of the position at HMRC. Send everything that should stand, not a delta."
      },
      "SaveMtdNominalMappingRequest": {
        "required": [
          "entries",
          "incomeSourceType"
        ],
        "type": "object",
        "properties": {
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MtdNominalMappingEntryDto"
            },
            "description": "Every account the practice has decided about, including the ones they decided to ignore (a\nnull target key). Accounts left out entirely are simply unmapped and will be asked about again."
          }
        },
        "additionalProperties": false,
        "description": "Confirms a client's chart-of-accounts mapping for one MTD business, replacing any previous one."
      },
      "SaveMtdNonPayeEmploymentRequest": {
        "type": "object",
        "properties": {
          "tips": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Tips received outside PAYE.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's non-PAYE employment income — tips received outside PAYE. A full replacement at\nHMRC."
      },
      "SaveMtdOtherCapitalGainsRequest": {
        "type": "object",
        "properties": {
          "cryptoassets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CryptoassetDisposal"
            },
            "description": "Crypto-asset disposals.",
            "nullable": true
          },
          "otherGains": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OtherGainDisposal"
            },
            "description": "Other gains — listed shares, other property and assets, and non-UK residential property.\nEach item carries HMRC's asset type.",
            "nullable": true
          },
          "unlistedShares": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UnlistedSharesDisposal"
            },
            "description": "Unlisted share disposals, with their EIS and SEIS relief interactions.",
            "nullable": true
          },
          "gainsFromExcludedIndexedSecurities": {
            "type": "number",
            "description": "Gains from excluded indexed securities.",
            "format": "double",
            "nullable": true
          },
          "qualifyingAssetHoldingCompany": {
            "$ref": "#/components/schemas/QahcGains"
          },
          "nonStandardGains": {
            "$ref": "#/components/schemas/NonStandardGains"
          },
          "losses": {
            "$ref": "#/components/schemas/CapitalLosses"
          },
          "adjustments": {
            "type": "number",
            "description": "Adjustment to the year's gains.",
            "format": "double",
            "nullable": true
          },
          "lifetimeAllowance": {
            "$ref": "#/components/schemas/LifetimeAllowances"
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's capital gains other than UK residential property at HMRC.\n            \nA <strong>full replacement</strong>: every disposal that should survive must be in the request,\nbecause what is absent is cleared. Editing one disposal means sending them all back — dropping\nthe others deletes them. Clearing the year is a delete, not an empty save."
      },
      "SaveMtdOtherEmploymentIncomeRequest": {
        "type": "object",
        "properties": {
          "shareOption": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ShareOptionItem"
            },
            "description": "Share option events. HMRC's scheme plan types are emi, csop, saye and other.",
            "nullable": true
          },
          "sharesAwardedOrReceived": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SharesAwardedOrReceivedItem"
            },
            "description": "Shares awarded or received. HMRC's scheme plan types are sip and other.",
            "nullable": true
          },
          "disability": {
            "$ref": "#/components/schemas/EmploymentDeductionItem"
          },
          "foreignService": {
            "$ref": "#/components/schemas/EmploymentDeductionItem"
          },
          "lumpSums": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmploymentLumpSums"
            },
            "description": "Lump sums, grouped by employer. HMRC require the employer identity on every entry.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's other employment income at HMRC — share options, shares awarded or received,\nlump sums, and the disability and foreign service deductions.\n            \nA <strong>full replacement</strong>: every entry that should survive must be in the request,\nbecause what is absent is cleared. Clearing the year is a delete, not an empty save."
      },
      "SaveMtdOtherReliefsRequest": {
        "type": "object",
        "properties": {
          "nonDeductibleLoanInterest": {
            "$ref": "#/components/schemas/ReliefClaim"
          },
          "payrollGiving": {
            "$ref": "#/components/schemas/ReliefClaim"
          },
          "qualifyingDistributionRedemptionOfSharesAndSecurities": {
            "$ref": "#/components/schemas/ReliefAmount"
          },
          "maintenancePayments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MaintenancePayment"
            },
            "description": "Maintenance payments to a former spouse or civil partner.",
            "nullable": true
          },
          "postCessationTradeReliefAndCertainOtherLosses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PostCessationRelief"
            },
            "description": "Post-cessation trade relief and certain other losses.",
            "nullable": true
          },
          "annualPaymentsMade": {
            "$ref": "#/components/schemas/ReliefClaim"
          },
          "qualifyingLoanInterestPayments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QualifyingLoanInterest"
            },
            "description": "Qualifying loan interest payments.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's other reliefs at HMRC — a full replacement, so every entry that should survive\nmust be in the request."
      },
      "SaveMtdOtherSavingsRequest": {
        "type": "object",
        "properties": {
          "securities": {
            "$ref": "#/components/schemas/SecuritiesIncome"
          },
          "foreignInterest": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignInterestItem"
            },
            "description": "Interest from foreign savings. HMRC require a country code and taxable amount on every item.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's other savings income — securities interest and foreign interest — at HMRC.\n            \nA <strong>full replacement</strong>: everything that should survive must be present, because\nwhat is absent is cleared. Clearing the year is a delete, not an empty save."
      },
      "SaveMtdPensionsReliefsRequest": {
        "type": "object",
        "properties": {
          "regularPensionContributions": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Regular pension contributions paid.",
            "format": "double",
            "nullable": true
          },
          "oneOffPensionContributionsPaid": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "One-off pension contributions paid.",
            "format": "double",
            "nullable": true
          },
          "retirementAnnuityPayments": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Retirement annuity payments.",
            "format": "double",
            "nullable": true
          },
          "paymentToEmployersSchemeNoTaxRelief": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Payments to an employer's scheme not deducted before tax.",
            "format": "double",
            "nullable": true
          },
          "overseasPensionSchemeContributions": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Contributions to overseas pension schemes.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's pension contribution reliefs at HMRC — a full replacement of all five figures,\nso send every one that should stand."
      },
      "SaveMtdQuarterlySubmissionRequest": {
        "required": [
          "businessId",
          "incomeSourceType",
          "periodEndDate",
          "periodStartDate",
          "taxYear"
        ],
        "type": "object",
        "properties": {
          "businessId": {
            "maxLength": 20,
            "minLength": 1,
            "type": "string",
            "description": "HMRC's identifier for the income source the figures belong to."
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "taxYear": {
            "maxLength": 7,
            "minLength": 1,
            "type": "string",
            "description": "The tax year, in HMRC's format, e.g. 2025-26."
          },
          "periodStartDate": {
            "type": "string",
            "description": "Start of the obligation period being answered — the start of the tax year.",
            "format": "date"
          },
          "periodEndDate": {
            "type": "string",
            "description": "End of the obligation period being answered — the quarter end.",
            "format": "date"
          },
          "selfEmploymentFigures": {
            "$ref": "#/components/schemas/SelfEmploymentFigureInputs"
          },
          "ukPropertyFigures": {
            "$ref": "#/components/schemas/UkPropertyFigures"
          },
          "foreignPropertyFigures": {
            "$ref": "#/components/schemas/ForeignPropertyFigureInputs"
          }
        },
        "additionalProperties": false,
        "description": "Saves the figures for an MTD quarterly update, creating the draft if it does not exist yet.\nA full replacement of the figures for that income source and tax year."
      },
      "SaveMtdSavingsAccountInterestRequest": {
        "type": "object",
        "properties": {
          "taxedUkInterest": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Interest paid with tax already taken off.",
            "format": "double",
            "nullable": true
          },
          "untaxedUkInterest": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Interest paid gross.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves one savings account's interest for a tax year — a full replacement of the pair at HMRC.\nOmitting one of the two clears it, so send both whenever both should stand.\n            \nHMRC offer no delete for account interest: clearing it means saving zeros."
      },
      "SaveMtdStudentLoanBenefitRequest": {
        "required": [
          "payrolledBenefits"
        ],
        "type": "object",
        "properties": {
          "payrolledBenefits": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Payrolled benefits which affect student loan repayments.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Saves the payrolled benefits that affect student loan repayments for one employment. A full\nreplacement at HMRC (2025-26 onwards)."
      },
      "SaveMtdTaxLiabilityAdjustmentsRequest": {
        "type": "object",
        "properties": {
          "carryBackLossesDecrease": {
            "$ref": "#/components/schemas/CarryBackLossesDecrease"
          },
          "taxRefundedOrSetOff": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Tax already refunded or set off for the year, as a positive figure.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Creates or amends a tax year's liability adjustments, a full replacement of what HMRC hold.\nSend every figure that should stand, not a delta. Clearing them is a delete, not an empty save."
      },
      "SaveMtdUkDividendsRequest": {
        "type": "object",
        "properties": {
          "ukDividends": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Dividends from UK companies.",
            "format": "double",
            "nullable": true
          },
          "otherUkDividends": {
            "maximum": 99999999999.99,
            "minimum": 0,
            "type": "number",
            "description": "Other UK dividends, e.g. from authorised unit trusts.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Saves the year's plain UK dividends at HMRC — a full replacement of the pair. Omitting one of\nthe two clears it, so send both whenever both should stand."
      },
      "SavePracticeNoteResponse": {
        "type": "object",
        "properties": {
          "saved": {
            "type": "boolean",
            "description": "Whether the note was written. False when somebody else saved first."
          },
          "note": {
            "$ref": "#/components/schemas/PracticeNoteDto"
          }
        },
        "additionalProperties": false,
        "description": "Result of saving the practice's shared note. A rejected save is an ordinary outcome of two\npeople editing at once rather than an error, so it comes back as a 200 the editor can act on."
      },
      "SaveRecurringTaskScheduleRequest": {
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "type": "string",
            "description": "Optional user label to tell schedules apart; shown instead of nothing when two schedules\nhave similar dates.",
            "nullable": true
          },
          "clientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The clients this schedule applies to - the complete membership, possibly empty.",
            "nullable": true
          },
          "schedule": {
            "$ref": "#/components/schemas/ScheduleConfigDto"
          }
        },
        "additionalProperties": false,
        "description": "Create or replace a schedule on a recurring task. On PUT the client list is the schedule's\nfull membership: listed clients get this schedule (moving here from another schedule if they\nhad one), clients omitted revert to whichever schedule they belong to otherwise. An empty\nlist is legal - a schedule can exist without clients. For the default schedule the list must\nbe empty; only its dates can change."
      },
      "SaveWorkflowStepClientDataRequest": {
        "type": "object",
        "properties": {
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepClientDataValueDto"
            },
            "description": "The field values to save to the client record.",
            "nullable": true
          },
          "markComplete": {
            "type": "boolean",
            "description": "Whether to mark the step as Completed after saving.\nWhen true, required field validation is enforced."
          }
        },
        "additionalProperties": false,
        "description": "Request to save client data values from an UpdateClientData workflow step."
      },
      "SavedClientFilterDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier within the tenant",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "User-friendly name for this saved filter",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional description providing more details about this filter's purpose",
            "nullable": true
          },
          "includeInMenu": {
            "type": "boolean",
            "description": "Whether the current user has this filter in their menu/quick access list.\nThis is a per-user preference — other users of a shared filter have their own setting."
          },
          "isShared": {
            "type": "boolean",
            "description": "Whether this filter is shared with all users in the tenant. Shared filters are\nvisible (read-only) to everyone; only the owner can modify or delete them."
          },
          "isOwner": {
            "type": "boolean",
            "description": "Whether the current user owns this filter"
          },
          "owner": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "managerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by manager code(s)",
            "nullable": true
          },
          "partnerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by partner code(s)",
            "nullable": true
          },
          "associateCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by associate code(s)",
            "nullable": true
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientStatus"
            },
            "description": "Filter by client status(es)",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "Filter by client type(s)",
            "nullable": true
          },
          "serviceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by billable service code(s)",
            "nullable": true
          },
          "packageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by service package code(s)",
            "nullable": true
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by team code(s)",
            "nullable": true
          },
          "serviceStageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by service stage composite codes (format: \"serviceCode:stageCode\")",
            "nullable": true
          },
          "serviceStatuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceStatus"
            },
            "description": "Service statuses a client's service must have: the chosen service's, or any service's when no service or stage is filtered. Null means any status.",
            "nullable": true
          },
          "customFieldFilters": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by custom field composite values (format: \"fieldCode:value\", or \"fieldCode:\" for blank)",
            "nullable": true
          },
          "keyDateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "keyDateRange": {
            "$ref": "#/components/schemas/PresetDateRange"
          },
          "keyDateFrom": {
            "type": "string",
            "description": "Start of the key date window. Only set when KeyDateRange is CustomDateRange.",
            "format": "date",
            "nullable": true
          },
          "keyDateTo": {
            "type": "string",
            "description": "End of the key date window. Only set when KeyDateRange is CustomDateRange.",
            "format": "date",
            "nullable": true
          },
          "defaultSortKeyDateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "defaultSortField": {
            "$ref": "#/components/schemas/ClientSortField"
          },
          "defaultSortDesc": {
            "type": "boolean",
            "description": "Sort in descending order (true) or ascending order (false)",
            "nullable": true
          },
          "iconName": {
            "type": "string",
            "description": "Optional Lucide icon name for visual identification (e.g., \"Calendar\", \"Users\", \"Star\")",
            "nullable": true
          },
          "color": {
            "type": "string",
            "description": "Optional hex color for visual identification (e.g., \"#FF5733\")",
            "nullable": true
          },
          "columnConfigJson": {
            "type": "string",
            "description": "Optional JSON column configuration for the saved view.\nWhen set, overrides the user's default client column preferences.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the filter was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the filter was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A saved client filter belonging to a tenant user, defining reusable criteria for filtering client lists"
      },
      "SavedClientFilterDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SavedClientFilterDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "SavedClientFilterSortField": {
        "enum": [
          "Name",
          "UpdatedDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "SavedTaskFilterDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier within the tenant",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "User-friendly name for this saved filter",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional description providing more details about this filter's purpose",
            "nullable": true
          },
          "includeInMenu": {
            "type": "boolean",
            "description": "Whether the current user has this filter in their menu/quick access list.\nThis is a per-user preference — other users of a shared filter have their own setting."
          },
          "isShared": {
            "type": "boolean",
            "description": "Whether this filter is shared with all users in the tenant. Shared filters are\nvisible (read-only) to everyone; only the owner can modify or delete them."
          },
          "isOwner": {
            "type": "boolean",
            "description": "Whether the current user owns this filter"
          },
          "owner": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "dateRange": {
            "$ref": "#/components/schemas/PresetDateRange"
          },
          "startDate": {
            "type": "string",
            "description": "Custom start date (only used when DateRange = CustomDateRange)",
            "format": "date",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "Custom end date (only used when DateRange = CustomDateRange)",
            "format": "date",
            "nullable": true
          },
          "dateBasis": {
            "$ref": "#/components/schemas/TaskDateBasis"
          },
          "clientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by client code(s)",
            "nullable": true
          },
          "userCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by user code(s)",
            "nullable": true
          },
          "recurringTaskCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by recurring task code(s)",
            "nullable": true
          },
          "categoryCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by category code(s)",
            "nullable": true
          },
          "serviceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by billable service code(s)",
            "nullable": true
          },
          "serviceStageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by billable service stage. Composite \"serviceCode:stageCode\" values, since a stage\ncode is only unique within its parent service.",
            "nullable": true
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by team code(s)",
            "nullable": true
          },
          "clientManagerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the primary client's manager (user codes). Clientless tasks never match.",
            "nullable": true
          },
          "clientPartnerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the primary client's partner (user codes). Clientless tasks never match.",
            "nullable": true
          },
          "clientAssociateCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the primary client's associate (user codes). Clientless tasks never match.",
            "nullable": true
          },
          "servicePreparerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the Preparer in force on the task's service (user codes). Tasks without one never match.",
            "nullable": true
          },
          "serviceReviewerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the Reviewer in force on the task's service (user codes). Tasks without one never match.",
            "nullable": true
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskItemStatus"
            },
            "description": "Filter by task status(es)",
            "nullable": true
          },
          "isOverdue": {
            "type": "boolean",
            "description": "Filter to only overdue tasks",
            "nullable": true
          },
          "isUnassigned": {
            "type": "boolean",
            "description": "Include tasks with no assigned user. Can be combined with UserCodes to show\ntasks that are either unassigned OR assigned to specific users.",
            "nullable": true
          },
          "isAutomationDisabled": {
            "type": "boolean",
            "description": "Filter by the automation switch: true for tasks with automation off, false for those with\nit on, null for both. Task previews are excluded whenever this is set.",
            "nullable": true
          },
          "includeProjected": {
            "type": "boolean",
            "description": "Include projected (virtual) tasks in the results"
          },
          "includeWorkflowSteps": {
            "type": "boolean",
            "description": "Include workflow steps in the results (Agenda mode)"
          },
          "defaultSortField": {
            "$ref": "#/components/schemas/TaskItemSortField"
          },
          "defaultSortDesc": {
            "type": "boolean",
            "description": "Sort in descending order (true) or ascending order (false)",
            "nullable": true
          },
          "iconName": {
            "type": "string",
            "description": "Optional Lucide icon name for visual identification (e.g., \"Calendar\", \"Users\", \"Star\")",
            "nullable": true
          },
          "color": {
            "type": "string",
            "description": "Optional hex color for visual identification (e.g., \"#FF5733\")",
            "nullable": true
          },
          "columnConfigJson": {
            "type": "string",
            "description": "Optional JSON column configuration for the saved view.\nWhen set, overrides the user's default task column preferences.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the filter was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the filter was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A saved task filter belonging to a tenant user, defining reusable criteria for filtering task lists"
      },
      "SavedTaskFilterDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SavedTaskFilterDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "SavedTaskFilterSortField": {
        "enum": [
          "Name",
          "UpdatedDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "SavingsAccountInterest": {
        "type": "object",
        "properties": {
          "taxedUkInterest": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "untaxedUkInterest": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ScheduleConfigDto": {
        "type": "object",
        "properties": {
          "basis": {
            "$ref": "#/components/schemas/TaskDateBasis"
          },
          "recurrence": {
            "$ref": "#/components/schemas/RecurrenceConfigDto"
          },
          "start": {
            "$ref": "#/components/schemas/TaskStartConfigDto"
          },
          "due": {
            "$ref": "#/components/schemas/DueDateConfigDto"
          },
          "statutory": {
            "$ref": "#/components/schemas/StatutoryDateConfigDto"
          }
        },
        "additionalProperties": false,
        "description": "Groups all scheduling configuration for a recurring task template: which date drives the\ncycle, how often it repeats, and how the Start/Due/Statutory dates are each calculated."
      },
      "ScheduledSendBlobAttachment": {
        "type": "object",
        "properties": {
          "blobName": {
            "type": "string",
            "description": "Blob path within the scheduled-send attachments container",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "description": "Original file name shown to the user and restored on the outgoing email",
            "nullable": true
          },
          "contentType": {
            "type": "string",
            "description": "MIME type of the attachment",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A raw uploaded attachment held in blob storage while its send is pending"
      },
      "ScheduledSendDetailDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying the scheduled send",
            "nullable": true
          },
          "sendType": {
            "$ref": "#/components/schemas/ScheduledSendType"
          },
          "status": {
            "$ref": "#/components/schemas/ScheduledSendStatus"
          },
          "scheduledAt": {
            "type": "string",
            "description": "UTC instant at which the send becomes due for dispatch",
            "format": "date-time"
          },
          "displaySubject": {
            "type": "string",
            "description": "Subject/title captured at schedule time for display",
            "nullable": true
          },
          "displayRecipients": {
            "type": "string",
            "description": "Recipient summary captured at schedule time for display",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When the send was scheduled",
            "format": "date-time"
          },
          "dispatchedAt": {
            "type": "string",
            "description": "When the send was dispatched (success or failure). Null while pending.",
            "format": "date-time",
            "nullable": true
          },
          "failureReason": {
            "type": "string",
            "description": "Why dispatch failed, when Status is Failed",
            "nullable": true
          },
          "payload": {
            "$ref": "#/components/schemas/ScheduledSendPayload"
          }
        },
        "additionalProperties": false,
        "description": "A scheduled send including its stored payload, used to prefill the edit dialogs"
      },
      "ScheduledSendDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying the scheduled send",
            "nullable": true
          },
          "sendType": {
            "$ref": "#/components/schemas/ScheduledSendType"
          },
          "status": {
            "$ref": "#/components/schemas/ScheduledSendStatus"
          },
          "scheduledAt": {
            "type": "string",
            "description": "UTC instant at which the send becomes due for dispatch",
            "format": "date-time"
          },
          "displaySubject": {
            "type": "string",
            "description": "Subject/title captured at schedule time for display",
            "nullable": true
          },
          "displayRecipients": {
            "type": "string",
            "description": "Recipient summary captured at schedule time for display",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When the send was scheduled",
            "format": "date-time"
          },
          "dispatchedAt": {
            "type": "string",
            "description": "When the send was dispatched (success or failure). Null while pending.",
            "format": "date-time",
            "nullable": true
          },
          "failureReason": {
            "type": "string",
            "description": "Why dispatch failed, when Status is Failed",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A pending, dispatched, cancelled or failed scheduled send, as shown on the Scheduled list"
      },
      "ScheduledSendDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScheduledSendDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ScheduledSendPayload": {
        "type": "object",
        "properties": {
          "configCode": {
            "type": "string",
            "description": "The mailbox (email config) to send from. Null on MailboxSend means automatic routing;\nrequired for MailboxEmail, MailboxReply and MailboxForward.",
            "nullable": true
          },
          "email": {
            "$ref": "#/components/schemas/SendMailboxEmailRequest"
          },
          "reply": {
            "$ref": "#/components/schemas/ReplyMailboxEmailRequest"
          },
          "replyToMessageId": {
            "type": "string",
            "description": "The email service message id being replied to, for MailboxReply sends",
            "format": "uuid",
            "nullable": true
          },
          "forward": {
            "$ref": "#/components/schemas/ForwardMailboxEmailRequest"
          },
          "forwardMessageId": {
            "type": "string",
            "description": "The email service message id being forwarded, for MailboxForward sends",
            "format": "uuid",
            "nullable": true
          },
          "taskCode": {
            "type": "string",
            "description": "Task code for WorkflowStep sends",
            "nullable": true
          },
          "groupNumber": {
            "type": "integer",
            "description": "Workflow group number for WorkflowStep sends",
            "format": "int32",
            "nullable": true
          },
          "stepNumber": {
            "type": "integer",
            "description": "Workflow step number for WorkflowStep sends",
            "format": "int32",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "Client code for DocumentRequestOpen, DataFormSend and DocumentApproval sends",
            "nullable": true
          },
          "documentRequestCode": {
            "type": "string",
            "description": "Code of the draft document request to open, for DocumentRequestOpen sends",
            "nullable": true
          },
          "documentRequestOpen": {
            "$ref": "#/components/schemas/OpenDocumentRequestRequest"
          },
          "dataFormCode": {
            "type": "string",
            "description": "Code of the data form to send, for DataFormSend and DataFormBulkSend sends",
            "nullable": true
          },
          "dataFormSend": {
            "$ref": "#/components/schemas/SendDataFormRequest"
          },
          "dataFormBulkSend": {
            "$ref": "#/components/schemas/BulkSendDataFormRequest"
          },
          "documentApproval": {
            "$ref": "#/components/schemas/RequestClientApprovalForDocumentsRequest"
          },
          "emailBroadcastCode": {
            "type": "string",
            "description": "Code of the broadcast to send, for EmailBroadcast sends",
            "nullable": true
          },
          "textBroadcastCode": {
            "type": "string",
            "description": "Code of the bulk text to send, for TextBroadcast sends",
            "nullable": true
          },
          "engagementCode": {
            "type": "string",
            "description": "Code of the proposal to email, for Proposal sends",
            "nullable": true
          },
          "proposalSend": {
            "$ref": "#/components/schemas/SendEngagementEmailRequest"
          },
          "blobAttachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScheduledSendBlobAttachment"
            },
            "description": "Raw uploaded attachments offloaded to blob storage at schedule time,\nrehydrated into the send request at dispatch",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The stored payload of a scheduled send — everything needed to replay the underlying send at\ndispatch time. Exactly one of the per-type payload sections is populated, matching the row's\nSendType. Raw uploaded attachments are offloaded to blob storage at schedule time and\nreferenced via BlobAttachments; practice document attachments stay as codes and are resolved\nat dispatch."
      },
      "ScheduledSendSortField": {
        "enum": [
          "ScheduledAt",
          "CreatedDate",
          "DisplaySubject",
          "SendType",
          "Status",
          "ClientName"
        ],
        "type": "string",
        "example": "ScheduledAt"
      },
      "ScheduledSendStatus": {
        "enum": [
          "Scheduled",
          "Dispatching",
          "Sent",
          "Cancelled",
          "Failed"
        ],
        "type": "string",
        "example": "Scheduled"
      },
      "ScheduledSendType": {
        "enum": [
          "MailboxEmail",
          "MailboxSend",
          "MailboxReply",
          "WorkflowStep",
          "DocumentRequestOpen",
          "DataFormSend",
          "DataFormBulkSend",
          "DocumentApproval",
          "EmailBroadcast",
          "MailboxForward",
          "Proposal",
          "TextBroadcast"
        ],
        "type": "string",
        "example": "MailboxEmail"
      },
      "SecuritiesIncome": {
        "type": "object",
        "properties": {
          "taxTakenOff": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "grossAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "netAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SecuritySettingsDto": {
        "type": "object",
        "properties": {
          "requireMfa": {
            "type": "boolean",
            "description": "Whether every user of this practice must complete multi-factor authentication to use the web\napp. Off by default. A user who belongs to more than one practice must use MFA if any of them\nrequires it."
          },
          "allowApiKeys": {
            "type": "boolean",
            "description": "Whether API keys may be used to access this practice. On by default. Switching it off rejects\nevery API-key request to this practice, including integrations that use a practice API key."
          },
          "hasXeroConnection": {
            "type": "boolean",
            "description": "Whether this practice has a live Xero connection. While it does, two-factor authentication\ncannot be switched off, because Xero requires it."
          }
        },
        "additionalProperties": false,
        "description": "Tenant-level security settings."
      },
      "SelfEmploymentAnnualAdjustments": {
        "type": "object",
        "properties": {
          "includedNonTaxableProfits": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "basisAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "overlapReliefUsed": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "accountingAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "averagingAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "outstandingBusinessIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "balancingChargeBpra": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "balancingChargeOther": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "goodsAndServicesOwnUse": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "transitionProfitAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "transitionProfitAccelerationAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adjustmentToProfitsForClass4": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentAnnualAllowances": {
        "type": "object",
        "properties": {
          "annualInvestmentAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "capitalAllowanceMainPool": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "capitalAllowanceSpecialRatePool": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "businessPremisesRenovationAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "enhancedCapitalAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "allowanceOnSales": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "capitalAllowanceSingleAssetPool": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "zeroEmissionsCarAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "tradingIncomeAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "firstYearAllowanceOnPlantAndMachinery": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "structuredBuildingAllowance": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StructuredBuildingAllowanceItem"
            },
            "nullable": true
          },
          "enhancedStructuredBuildingAllowance": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StructuredBuildingAllowanceItem"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentAnnualNonFinancials": {
        "type": "object",
        "properties": {
          "businessDetailsChangedRecently": {
            "type": "boolean",
            "nullable": true
          },
          "class4NicsExemptionReason": {
            "$ref": "#/components/schemas/Class4NicsExemptionReason"
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentAnnualSubmission": {
        "type": "object",
        "properties": {
          "adjustments": {
            "$ref": "#/components/schemas/SelfEmploymentAnnualAdjustments"
          },
          "allowances": {
            "$ref": "#/components/schemas/SelfEmploymentAnnualAllowances"
          },
          "nonFinancials": {
            "$ref": "#/components/schemas/SelfEmploymentAnnualNonFinancials"
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentBsas": {
        "type": "object",
        "properties": {
          "metadata": {
            "$ref": "#/components/schemas/BsasMetadata"
          },
          "inputs": {
            "$ref": "#/components/schemas/BsasInputs"
          },
          "adjustableSummaryCalculation": {
            "$ref": "#/components/schemas/SelfEmploymentBsasCalculation"
          },
          "adjustments": {
            "$ref": "#/components/schemas/SelfEmploymentBsasAdjustments"
          },
          "adjustedSummaryCalculation": {
            "$ref": "#/components/schemas/SelfEmploymentBsasCalculation"
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentBsasAccountingAdjustments": {
        "type": "object",
        "properties": {
          "basisAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "overlapReliefUsed": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "accountingAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "averagingAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentBsasAdditions": {
        "type": "object",
        "properties": {
          "costOfGoodsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "paymentsToSubcontractorsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "wagesAndStaffCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "carVanTravelExpensesDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "premisesRunningCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "maintenanceCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adminCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "interestOnBankOtherLoansDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "financeChargesDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "irrecoverableDebtsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "professionalFeesDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "depreciationDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherExpensesDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "advertisingCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "businessEntertainmentCostsDisallowable": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "outstandingBusinessIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "balancingChargeOther": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "balancingChargeBpra": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "goodsAndServicesOwnUse": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentBsasAdjustmentInputs": {
        "type": "object",
        "properties": {
          "income": {
            "$ref": "#/components/schemas/SelfEmploymentBsasIncome"
          },
          "expenses": {
            "$ref": "#/components/schemas/SelfEmploymentBsasExpenses"
          },
          "additions": {
            "$ref": "#/components/schemas/SelfEmploymentBsasAdditions"
          }
        },
        "additionalProperties": false,
        "description": "The sole-trade adjustment figures, as deltas."
      },
      "SelfEmploymentBsasAdjustments": {
        "type": "object",
        "properties": {
          "income": {
            "$ref": "#/components/schemas/SelfEmploymentBsasIncome"
          },
          "expenses": {
            "$ref": "#/components/schemas/SelfEmploymentBsasExpenses"
          },
          "additions": {
            "$ref": "#/components/schemas/SelfEmploymentBsasAdditions"
          },
          "zeroAdjustments": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentBsasCalculation": {
        "type": "object",
        "properties": {
          "totalIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "income": {
            "$ref": "#/components/schemas/SelfEmploymentBsasIncome"
          },
          "totalExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "expenses": {
            "$ref": "#/components/schemas/SelfEmploymentBsasExpenses"
          },
          "netProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "netLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalAdditions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "additions": {
            "$ref": "#/components/schemas/SelfEmploymentBsasAdditions"
          },
          "totalDeductions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "deductions": {
            "$ref": "#/components/schemas/SelfEmploymentBsasDeductions"
          },
          "totalAccountingAdjustments": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "accountingAdjustments": {
            "$ref": "#/components/schemas/SelfEmploymentBsasAccountingAdjustments"
          },
          "taxableProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adjustedIncomeTaxLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentBsasDeductions": {
        "type": "object",
        "properties": {
          "tradingAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "annualInvestmentAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "capitalAllowanceMainPool": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "capitalAllowanceSpecialRatePool": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "zeroEmissionGoods": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "businessPremisesRenovationAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "enhancedCapitalAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "allowanceOnSales": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "capitalAllowanceSingleAssetPool": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "includedNonTaxableProfits": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "structuredBuildingAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "enhancedStructuredBuildingAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "zeroEmissionsCarAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "electricChargePointAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "firstYearAllowanceOnPlantAndMachinery": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentBsasExpenses": {
        "type": "object",
        "properties": {
          "costOfGoods": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "paymentsToSubcontractors": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "wagesAndStaffCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "carVanTravelExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "premisesRunningCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "maintenanceCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adminCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "interestOnBankOtherLoans": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "financeCharges": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "irrecoverableDebts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "professionalFees": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "depreciation": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "advertisingCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "businessEntertainmentCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "consolidatedExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentBsasIncome": {
        "type": "object",
        "properties": {
          "turnover": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "other": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentCumulativeSummary": {
        "type": "object",
        "properties": {
          "periodDates": {
            "$ref": "#/components/schemas/CumulativePeriodDates"
          },
          "periodIncome": {
            "$ref": "#/components/schemas/CumulativeIncome"
          },
          "periodExpenses": {
            "$ref": "#/components/schemas/CumulativeExpenses"
          },
          "periodDisallowableExpenses": {
            "$ref": "#/components/schemas/CumulativeDisallowableExpenses"
          }
        },
        "additionalProperties": false
      },
      "SelfEmploymentFigureInputs": {
        "type": "object",
        "properties": {
          "periodIncome": {
            "$ref": "#/components/schemas/CumulativeIncome"
          },
          "periodExpenses": {
            "$ref": "#/components/schemas/CumulativeExpenses"
          },
          "periodDisallowableExpenses": {
            "$ref": "#/components/schemas/CumulativeDisallowableExpenses"
          }
        },
        "additionalProperties": false
      },
      "SendClientMessagingMessageRequest": {
        "required": [
          "to"
        ],
        "type": "object",
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "body": {
            "maxLength": 4000,
            "minLength": 0,
            "type": "string",
            "description": "The text: required unless a template is sent, and empty when one is. At most 1,600 characters\nfor SMS and 4,000 for WhatsApp.",
            "nullable": true
          },
          "whatsAppTemplateId": {
            "type": "string",
            "description": "WhatsApp only: the template to send, by its id from the WhatsApp templates list; its live version\nis sent. A template may be sent at any time; free text only within 24 hours of the recipient's\nlast WhatsApp message. 409 messaging_whatsapp_template_not_approved when Meta has not approved any\nversion of it yet; 404 for an id the practice has no template for.",
            "format": "uuid",
            "nullable": true
          },
          "contentVariables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The template's variables by name (`{\"1\": \"Friday\"}`); any left out take the template's\ndefaults. Only with `whatsAppTemplateId`.",
            "nullable": true
          },
          "templateCode": {
            "maxLength": 100,
            "type": "string",
            "description": "A practice text template's code (from the templates list): its body is rendered on the server for\nthis recipient with the client's details as they are now, and sent as free text, so on WhatsApp only\nwithin the 24-hour window.",
            "nullable": true
          },
          "to": {
            "maxLength": 30,
            "minLength": 0,
            "type": "string",
            "description": "The recipient: a number held by the client or one of its contacts, E.164 or UK national format"
          }
        },
        "additionalProperties": false,
        "description": "A message sent from a client record to one of the client's own numbers or one of its contacts'."
      },
      "SendDataFormExecutionStateDto": {
        "type": "object",
        "properties": {
          "dataFormRequestCode": {
            "type": "string",
            "description": "The code of the created data form request.",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The client code the form was sent to.",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "description": "UTC timestamp of when the form request was created.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Execution state for a SendDataForm workflow step.\nContains information about the created data form request after execution."
      },
      "SendDataFormRequest": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The code of the client to send the form to",
            "nullable": true
          },
          "notifyUserCode": {
            "type": "string",
            "description": "The user to notify when the client submits their response. If not specified, no notification is sent.",
            "nullable": true
          },
          "autoAcceptData": {
            "type": "boolean",
            "description": "When true, submitted data will be automatically accepted and copied to the client record without manual review"
          },
          "message": {
            "type": "string",
            "description": "A message explaining what the client needs to do, included in the notification email",
            "nullable": true
          },
          "recipients": {
            "$ref": "#/components/schemas/EmailRecipientConfig"
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for the chase frequency in days. If not specified, the tenant default is used;\n0 switches chasing off.",
            "format": "int32",
            "nullable": true
          },
          "scheduledAt": {
            "type": "string",
            "description": "When set, the form is not sent now: no form request is created until a scheduled send\ndispatches it at this UTC instant. Must be in the future. Omit to send immediately.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for sending a form to a single client"
      },
      "SendDataFormStepConfigDto": {
        "type": "object",
        "properties": {
          "dataForm": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "message": {
            "type": "string",
            "description": "Optional message override. When null, the form's DefaultMessage is used.",
            "nullable": true
          },
          "autoAcceptData": {
            "type": "boolean",
            "description": "Whether submitted data is automatically accepted without manual review."
          },
          "notifyAssigneeOnSubmission": {
            "type": "boolean",
            "description": "Whether to send a platform notification to the step's assigned user when the client submits."
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to send the form notification email to the client's business email\n(the email address on the client record)."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types to send the form notification email to.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to send the form notification to.",
            "nullable": true
          },
          "chaseFrequencyDays": {
            "type": "integer",
            "description": "Override for how often (in days) to chase this form request.\nWhen null, the tenant-level default is used.",
            "format": "int32",
            "nullable": true
          },
          "alsoSendText": {
            "type": "boolean",
            "description": "Also text each email recipient who is one of the client's contacts with a mobile, by SMS, with the same link as\ntheir email, worded by the practice's text wording for this kind of request. Ignored while the practice's\nmessaging is not Active."
          }
        },
        "additionalProperties": false,
        "description": "Configuration for SendDataForm workflow steps.\nUsed for both workflow template definition and task workflow step instance customization."
      },
      "SendDirectDebitSetupEmailRequest": {
        "required": [
          "email"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "minLength": 1,
            "type": "string",
            "format": "email"
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "callbackUrl": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SendEmailBroadcastRequest": {
        "type": "object",
        "properties": {
          "scheduledAt": {
            "type": "string",
            "description": "When set, the broadcast is not sent now: it moves to Scheduled status and is dispatched\nat this UTC instant. Must be in the future. Recipients are resolved and snapshotted at\ndispatch time, not schedule time.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Optional body for the send broadcast endpoint. An empty body (or null ScheduledAt)\nsends immediately, exactly as before."
      },
      "SendEmailResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Indicates if the request was accepted"
          },
          "messageId": {
            "type": "string",
            "description": "Unique ID of the queued message",
            "format": "uuid",
            "nullable": true
          },
          "errorMessage": {
            "type": "string",
            "description": "Error message if request failed",
            "nullable": true
          },
          "validationErrors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "description": "Validation errors if any",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response from send email request"
      },
      "SendEngagementEmailRequest": {
        "type": "object",
        "properties": {
          "addToPipeline": {
            "type": "boolean",
            "description": "Whether to add the client to a sales pipeline as part of this send. Null falls back to the\ntenant's Proposal Settings; false skips the add for this send only. Has no effect when\n\"Add Client to Sales Pipeline\" is switched off for the tenant — the send screen can opt out\nof the practice default, not opt in to it.",
            "nullable": true
          },
          "pipelineCode": {
            "type": "string",
            "description": "Sales pipeline to add the client to, overriding the one configured in Proposal Settings for\nthis send only. Null uses the configured pipeline. Ignored when AddToPipeline is false.",
            "nullable": true
          },
          "scheduledAt": {
            "type": "string",
            "description": "When set, the email is not sent now: a scheduled send emails the proposal at this UTC instant\nand the endpoint returns 202. The proposal keeps its status until then.",
            "format": "date-time",
            "nullable": true
          },
          "senderMailboxCode": {
            "type": "string",
            "description": "The mailbox to send from, when the sender chose one other than the practice's usual sender. Null follows the\npractice's client email sender rule. Refused unless the practice allows the choice (Email Settings) and the\nsender may send from the mailbox.",
            "nullable": true
          },
          "composedSubject": {
            "maxLength": 1000,
            "type": "string",
            "description": "The subject as the sender edited it in the composer, from the email preview. Sent with\n`composedBodyHtml` in place of the practice's proposal email template; omit both to send the template.",
            "nullable": true
          },
          "composedBodyHtml": {
            "type": "string",
            "description": "The body as the sender edited it in the composer, from the email preview. Sent as it stands inside the\npractice's email header and footer. A scheduled send keeps it and sends it at the scheduled time.",
            "nullable": true
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "People to copy in, beside the proposal's recipient. They get the same email and the same link.",
            "nullable": true
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "People to copy in without the other recipients seeing them.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Optional per-send options for emailing an engagement. The body may be omitted entirely, in which\ncase the tenant's Proposal Settings decide everything."
      },
      "SendHmrcAuthorisationRequestDto": {
        "required": [
          "authorisationTypes"
        ],
        "type": "object",
        "properties": {
          "authorisationTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentAuthorisationType"
            },
            "description": "The auth types to request (must have an [HmrcDigitalAuth] attribute)"
          },
          "clientId": {
            "type": "string",
            "description": "The HMRC client identifier (NINO for MTD-IT, VRN for MTD-VAT).\nRequired for digital flow types. Ignored for letter-based types (resolved from client data).",
            "nullable": true
          },
          "knownFact": {
            "type": "string",
            "description": "The known fact for verification (postcode for MTD-IT, VAT reg date for MTD-VAT).\nRequired for digital flow types. Ignored for letter-based types.",
            "nullable": true
          },
          "recipientEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Email addresses to send the authorisation links to. Not required if SuppressEmail is true.",
            "nullable": true
          },
          "postcode": {
            "type": "string",
            "description": "The client's postcode. Used for SA and CT letter-based requests (required by HMRC schema).\nIf not provided, extracted from the client's contact address.",
            "nullable": true
          },
          "nino": {
            "type": "string",
            "description": "National Insurance number. Used for SA letter-based requests (optional).\nIf not provided, resolved from the client's main contact.",
            "nullable": true
          },
          "accountsOfficeRef": {
            "type": "string",
            "description": "Accounts Office Reference. Used for PAYE and CIS letter-based requests.\nIf not provided, resolved from the client's business details.",
            "nullable": true
          },
          "companyRegNumber": {
            "type": "string",
            "description": "Companies House registration number. Used for CT letter-based requests.\nIf not provided, resolved from the client's business details.",
            "nullable": true
          },
          "yourReference": {
            "type": "string",
            "description": "Your internal reference for this client. Used in all letter-based requests.\nIf not provided, defaults to InternalReference or client code.",
            "nullable": true
          },
          "hmrcCredentialCode": {
            "maxLength": 100,
            "type": "string",
            "description": "Code of the HMRC credential set whose Government Gateway login makes the letter-based requests.\nNull uses the default set. Ignored for digital types.",
            "nullable": true
          },
          "suppressEmail": {
            "type": "boolean",
            "description": "If true, create the invitations with HMRC but do not send the email to the client."
          },
          "authCodeEntryDelayDays": {
            "maximum": 60,
            "minimum": 0,
            "type": "integer",
            "description": "For letter-based requests: how many days after this request to email the client the link they\nuse to enter the code HMRC posts them. 0 sends it as soon as HMRC accept the request.\n**Null means do not invite the client at all** — the practice will collect the code themselves.",
            "format": "int32",
            "nullable": true
          },
          "senderMailboxCode": {
            "maxLength": 100,
            "type": "string",
            "description": "Code of the mailbox the request's emails go from: the request email and the code entry link, including one\nthe daily schedule sends later. Null follows the practice's client email sender rule. The requester must be\nallowed to send from it.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to send HMRC agent authorisation requests for multiple types at once.\nSupports both digital (MTD) and letter-based (SA, CT, PAYE/CIS) flows transparently."
      },
      "SendInvitationRequest": {
        "required": [
          "email",
          "tenantCode"
        ],
        "type": "object",
        "properties": {
          "email": {
            "minLength": 1,
            "type": "string",
            "description": "The email address of the user to send the invitation to",
            "format": "email"
          },
          "tenantCode": {
            "minLength": 1,
            "type": "string",
            "description": "The tenant code for the invitation"
          }
        },
        "additionalProperties": false,
        "description": "Request model for sending an invitation to a user"
      },
      "SendMailboxEmailRequest": {
        "required": [
          "to"
        ],
        "type": "object",
        "properties": {
          "subject": {
            "type": "string",
            "description": "Email subject line (optional; defaults to an empty subject when omitted)",
            "nullable": true
          },
          "htmlBody": {
            "type": "string",
            "description": "HTML body of the email",
            "nullable": true
          },
          "plainTextBody": {
            "type": "string",
            "description": "Plain text body of the email (used as fallback when HTML is not supported)",
            "nullable": true
          },
          "to": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "List of To recipients (at least one required)"
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "List of CC recipients (optional)",
            "nullable": true
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "List of BCC recipients (optional)",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAttachmentDto"
            },
            "description": "List of attachments as base64-encoded content (optional)",
            "nullable": true
          },
          "addHeaderFooter": {
            "type": "boolean",
            "description": "Whether to wrap the body with the tenant's configured header/footer before sending. Defaults to false when omitted."
          },
          "practiceDocumentCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of practice documents (tenant document library) to attach. Resolved to file\ncontent server-side, so the browser never round-trips the document bytes.",
            "nullable": true
          },
          "scheduledAt": {
            "type": "string",
            "description": "When set, the email is not sent now: a scheduled send is created and dispatched at this\nUTC instant. Must be in the future. Omit to send immediately.",
            "format": "date-time",
            "nullable": true
          },
          "taskItemCode": {
            "type": "string",
            "description": "The task the email was written from. Once the email service reports it sent, its conversation is\nlinked to the task and shows on the task's Email tab.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for sending a new email from a tenant's connected mailbox."
      },
      "SendMessagingMessageRequest": {
        "type": "object",
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "body": {
            "maxLength": 4000,
            "minLength": 0,
            "type": "string",
            "description": "The text: required unless a template is sent, and empty when one is. At most 1,600 characters\nfor SMS and 4,000 for WhatsApp.",
            "nullable": true
          },
          "whatsAppTemplateId": {
            "type": "string",
            "description": "WhatsApp only: the template to send, by its id from the WhatsApp templates list; its live version\nis sent. A template may be sent at any time; free text only within 24 hours of the recipient's\nlast WhatsApp message. 409 messaging_whatsapp_template_not_approved when Meta has not approved any\nversion of it yet; 404 for an id the practice has no template for.",
            "format": "uuid",
            "nullable": true
          },
          "contentVariables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The template's variables by name (`{\"1\": \"Friday\"}`); any left out take the template's\ndefaults. Only with `whatsAppTemplateId`.",
            "nullable": true
          },
          "templateCode": {
            "maxLength": 100,
            "type": "string",
            "description": "A practice text template's code (from the templates list): its body is rendered on the server for\nthis recipient with the client's details as they are now, and sent as free text, so on WhatsApp only\nwithin the 24-hour window.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A reply on a conversation, to its number: free text (`body`), on WhatsApp an approved template\n(`whatsAppTemplateId` + `contentVariables`), or a practice text template (`templateCode`),\nexactly one. The annotations are the Messaging Service's own, so a bad request is refused before it\nis sent."
      },
      "SendTextBroadcastRequest": {
        "type": "object",
        "properties": {
          "scheduledAt": {
            "type": "string",
            "description": "When set, the bulk text is not sent now: it moves to Scheduled and is sent at this UTC instant, which must be in\nthe future and outside the practice's quiet hours. Its recipients are resolved and its balance checked again then.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Optional body for the send bulk text route. An empty body (or no ScheduledAt) sends it now."
      },
      "SendTextMessageExecutionStateDto": {
        "type": "object",
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "isPracticeRouted": {
            "type": "boolean",
            "description": "The run was on the practice's default: the practice's routing chose each recipient's channel"
          },
          "recipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextMessageRecipientDto"
            },
            "description": "The people texted or tried, one per number",
            "nullable": true
          },
          "missed": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextMessageMissedDto"
            },
            "description": "The people chosen who were never texted, and why",
            "nullable": true
          },
          "sentAt": {
            "type": "string",
            "description": "When the step completed (UTC); null until it has",
            "format": "date-time",
            "nullable": true
          },
          "blockReason": {
            "$ref": "#/components/schemas/TextMessageBlockReason"
          }
        },
        "additionalProperties": false,
        "description": "What a Send Text Message step did. Read-only: written by the system. The people missed are the\nSodiumHQ.DTOs.WorkflowSteps.SendTextMessageExecutionStateDto.Missed list with the recipients whose status is Failed."
      },
      "SendTextMessageStepConfigDto": {
        "type": "object",
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "isPracticeRouted": {
            "type": "boolean",
            "description": "The practice's default: the practice's text routing (SMS only, WhatsApp for known numbers, or try WhatsApp first)\nchooses the channel for each number when the step runs. The step then needs both an SMS text (templateCode or\nbody) and a WhatsApp template with its variables; a number that can't have the WhatsApp message gets the SMS."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "The client contact types to text, on each contact's mobile; at least one. One number under two types gets one\ntext.",
            "nullable": true
          },
          "templateCode": {
            "type": "string",
            "description": "SMS: the practice text template to send. Exactly one of this and body.",
            "nullable": true
          },
          "body": {
            "type": "string",
            "description": "SMS: the text, at most 1,600 characters, with the step emails' tokens ({{ Client.* }}, {{ Task.* }},\n{{ Contact.* }} for the person receiving it, {{ Url }} for the practice's portal). Exactly one of this and\ntemplateCode.",
            "nullable": true
          },
          "whatsAppTemplateId": {
            "type": "string",
            "description": "WhatsApp: the WhatsApp template to send, by its id from the WhatsApp templates list. Its live version is sent, so\nit must be approved and the step must map exactly its variables; a change waiting for Meta is ignored. Required on\nWhatsApp and on the practice's default, not allowed on SMS.",
            "format": "uuid",
            "nullable": true
          },
          "contentVariables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "WhatsApp: each of the template's variables (\"1\", \"2\"…) to the text rendered into it for each recipient, with the\nsame tokens as body. Every variable of the template must be mapped.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for Send Text Message workflow steps: who to text on their mobile, on which channel, and what\n(docs/features/WorkflowTextMessages/PLAN.md). SMS sends a practice text template or the step's own text, exactly\none. WhatsApp sends an approved WhatsApp template, with each of its variables mapped to a token expression."
      },
      "ServiceBillForWorkCoverageDto": {
        "type": "object",
        "properties": {
          "hasBillForWorkStep": {
            "type": "boolean",
            "description": "True when an active recurring task for the service uses a workflow with a Bill for Work step.\nFalse means nothing bills the service unless a Bill for Work step is added by hand to its tasks."
          }
        },
        "additionalProperties": false,
        "description": "Whether anything bills a service set to bill when the work is done."
      },
      "ServiceBudgetDto": {
        "type": "object",
        "properties": {
          "period": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "hoursMode": {
            "$ref": "#/components/schemas/StandardHoursMode"
          },
          "budgetMinutes": {
            "type": "integer",
            "description": "The typed standard hours in minutes per period, when HoursMode is Fixed",
            "format": "int32",
            "nullable": true
          },
          "typicalStepMinutes": {
            "type": "integer",
            "description": "About how many minutes of step estimates a typical period holds, from the linked recurring\ntasks' cadence and estimates. An approximation; null when no linked task has an estimate",
            "format": "int32",
            "nullable": true
          },
          "feeMode": {
            "$ref": "#/components/schemas/StandardFeeMode"
          },
          "feeAmount": {
            "type": "number",
            "description": "The standard fee per period, when FeeMode is Fixed",
            "format": "double",
            "nullable": true
          },
          "hourlyRate": {
            "type": "number",
            "description": "The service's charge-out rate today, else the practice default hourly rate; null without one. For\nshowing the hours at the practice's rates beside the fee (R2): information only, never a fee default",
            "format": "double",
            "nullable": true
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceBudgetStageDto"
            },
            "description": "Every stage of the service in board order with its figures; used when hours or the fee are by\nstage (D10), figures null where none is typed",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A catalogue service's standard budget (docs/features/ClientJobBudgets/PLAN.md). The fee fields\nare null for callers without Fee Budgets ViewAll, and for everyone while the practice has fee\nbudgets off."
      },
      "ServiceBudgetOverrideDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client's name",
            "nullable": true
          },
          "clientServiceCode": {
            "type": "string",
            "description": "The client service's code",
            "nullable": true
          },
          "hoursMode": {
            "$ref": "#/components/schemas/ClientBudgetMode"
          },
          "hoursAdjustPercent": {
            "type": "number",
            "description": "The client's hours percentage, under StandardAdjusted",
            "format": "double",
            "nullable": true
          },
          "hoursLines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetLineDto"
            },
            "description": "The hours lines, the overridden ones carrying OverrideFigure",
            "nullable": true
          },
          "feeMode": {
            "$ref": "#/components/schemas/ClientBudgetMode"
          },
          "feeAdjustPercent": {
            "type": "number",
            "description": "The client's fee percentage, under StandardAdjusted",
            "format": "double",
            "nullable": true
          },
          "feeLines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetLineDto"
            },
            "description": "The fee lines, the overridden ones carrying OverrideFigure",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A client service with figures of its own on a catalogue service, for the service's Budgets tab.\nLines are for the client's current period. Fee fields are null without Fee Budgets ViewAll."
      },
      "ServiceBudgetStageDto": {
        "type": "object",
        "properties": {
          "stageCode": {
            "type": "string",
            "nullable": true
          },
          "stageName": {
            "type": "string",
            "nullable": true
          },
          "budgetMinutes": {
            "type": "integer",
            "description": "The stage's standard hours in minutes, when hours are by stage and it has a figure",
            "format": "int32",
            "nullable": true
          },
          "feeAmount": {
            "type": "number",
            "description": "The stage's standard fee, when the fee is by stage and it has a figure",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One stage of a service's standard"
      },
      "ServiceBulkUpdateResult": {
        "type": "object",
        "properties": {
          "updatedCount": {
            "type": "integer",
            "format": "int32"
          },
          "skippedPackageCount": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "ServiceCatalogImportResultDto": {
        "type": "object",
        "properties": {
          "createdCount": {
            "type": "integer",
            "description": "Number of services created",
            "format": "int32"
          },
          "updatedCount": {
            "type": "integer",
            "description": "Number of existing services updated",
            "format": "int32"
          },
          "failedCount": {
            "type": "integer",
            "description": "Number of selected rows that failed to import",
            "format": "int32"
          },
          "contentBlocksCreated": {
            "type": "integer",
            "description": "Number of content blocks created (service terms and proposal content)",
            "format": "int32"
          },
          "contentBlocksReused": {
            "type": "integer",
            "description": "Number of times a service reused a content block instead of creating one\n(identical terms within the batch, or an update whose existing linked block already matched)",
            "format": "int32"
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceCatalogImportRowResultDto"
            },
            "description": "Per-row outcomes, in selection order",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of a services catalog CSV import"
      },
      "ServiceCatalogImportRowDto": {
        "type": "object",
        "properties": {
          "rowId": {
            "type": "string",
            "description": "Stable key for this row within the file: the Ignition #ID, the native Code,\nor a synthetic \"row-{n}\" for native rows without a code",
            "nullable": true
          },
          "action": {
            "type": "string",
            "description": "What importing this row will do: \"Create\", \"Update\" (native row whose Code matches\nan existing service) or \"Skip\" (unusable row — see SkipReason)",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The service name",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Plain-text service description (HTML from the source file is stripped)",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "The mapped service category code (falls back to Other when the source value is missing or unrecognised)",
            "nullable": true
          },
          "vatRate": {
            "$ref": "#/components/schemas/VatRate"
          },
          "pricing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceCatalogPricingEntryDto"
            },
            "description": "The pricing options parsed from the row, one per billing frequency.\nIgnition rows always land on Monthly (its export carries no frequency).",
            "nullable": true
          },
          "setupFee": {
            "type": "number",
            "description": "One-off setup fee, when present in the file (native format only)",
            "format": "double",
            "nullable": true
          },
          "minPrice": {
            "type": "number",
            "description": "Minimum of an Ignition \"price range\" row — display hint only, the default price uses this value",
            "format": "double",
            "nullable": true
          },
          "maxPrice": {
            "type": "number",
            "description": "Maximum of an Ignition \"price range\" row — display hint only",
            "format": "double",
            "nullable": true
          },
          "priceType": {
            "type": "string",
            "description": "The raw Ignition price type (\"fixed\", \"price range\", \"included\"); null for native rows",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "Whether the source row is archived/inactive"
          },
          "hasServiceTerms": {
            "type": "boolean",
            "description": "Whether the row carries service terms HTML that will become a content block"
          },
          "serviceTermsGroup": {
            "type": "integer",
            "description": "1-based group index shared by rows whose service terms are identical\n(they will share one content block); null when the row has no terms",
            "format": "int32",
            "nullable": true
          },
          "hasProposalContent": {
            "type": "boolean",
            "description": "Whether the row carries proposal content HTML that will become a content block\n(the native \"Proposal Content\" column, or an Ignition row's rich description)"
          },
          "proposalContentGroup": {
            "type": "integer",
            "description": "1-based group index shared by rows whose proposal content is identical\n(they will share one content block); null when the row has no proposal content",
            "format": "int32",
            "nullable": true
          },
          "isDuplicate": {
            "type": "boolean",
            "description": "Whether a create row's name matches an existing service (case-insensitive) —\nimporting it would produce a near-duplicate"
          },
          "defaultSelected": {
            "type": "boolean",
            "description": "Whether the row should be pre-ticked in the review grid"
          },
          "skipReason": {
            "type": "string",
            "description": "Why the row cannot be imported (e.g. \"Missing service name\", \"Invalid price\"); null for usable rows",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single service parsed from an uploaded services catalog CSV, ready for user review.\nReturned by the analyze endpoint; the RowId is the key used in the import selections."
      },
      "ServiceCatalogImportRowResultDto": {
        "type": "object",
        "properties": {
          "rowId": {
            "type": "string",
            "description": "The RowId from the selection this result relates to",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The service name from the CSV row (empty when the RowId was not found in the file)",
            "nullable": true
          },
          "action": {
            "type": "string",
            "description": "What was attempted: \"Create\", \"Update\" or \"Skip\"",
            "nullable": true
          },
          "success": {
            "type": "boolean",
            "description": "Whether the row imported successfully"
          },
          "serviceCode": {
            "type": "string",
            "description": "The code of the created or updated service; null on failure",
            "nullable": true
          },
          "serviceTermsContentCode": {
            "type": "string",
            "description": "The code of the service terms content block linked to the service; null when the row has no terms",
            "nullable": true
          },
          "proposalContentCode": {
            "type": "string",
            "description": "The code of the proposal content block linked to the service; null when the row has no proposal content",
            "nullable": true
          },
          "error": {
            "type": "string",
            "description": "Why the row failed; null on success",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of importing a single selected row"
      },
      "ServiceCatalogPricingEntryDto": {
        "type": "object",
        "properties": {
          "frequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "price": {
            "type": "number",
            "description": "The price at this frequency",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "A single price at a billing frequency for an imported service"
      },
      "ServiceCategoryDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this service category",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the service category, including this tenant's customisation of a system\ncategory where one has been made",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying service categories",
            "format": "int32"
          },
          "color": {
            "type": "string",
            "description": "The color associated with this service category",
            "nullable": true
          },
          "isSystem": {
            "type": "boolean",
            "description": "True for a built-in category supplied by Sodium. System categories can be renamed, reordered\nand recoloured per tenant, but cannot be deleted."
          }
        },
        "additionalProperties": false,
        "description": "A grouping used to classify billable services"
      },
      "ServiceCategoryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceCategoryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ServiceCategorySortField": {
        "enum": [
          "SortOrder",
          "Name"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "ServiceCsvAnalysisDto": {
        "type": "object",
        "properties": {
          "source": {
            "$ref": "#/components/schemas/ServiceImportSource"
          },
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DetectedServiceDto"
            },
            "description": "The services detected in the file, for mapping to billable services.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Result of analysing a foreign service CSV: the detected source and the services to map.\nWhether each service carries a price/frequency is on the service (DetectedServiceDto.IncludesPricing)."
      },
      "ServiceDeliveryReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/ServiceDeliverySummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/ServiceDeliveryRowDtoPagedResult"
          },
          "generatedAt": {
            "type": "string",
            "description": "UTC timestamp the report was computed - the report is a point-in-time snapshot, not live.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Service Delivery Turnaround report: headline KPIs plus the breakdown table for the\nrequested grouping. The common report response shape - summary, rows, generatedAt."
      },
      "ServiceDeliveryRowDto": {
        "type": "object",
        "properties": {
          "groupCode": {
            "type": "string",
            "description": "Entity code (service/client/user/team code, or \"yyyy-MM\" for months).\nNull for the null buckets (\"No service\", \"No client\", \"Unassigned\").",
            "nullable": true
          },
          "groupKind": {
            "$ref": "#/components/schemas/ReportGroupKind"
          },
          "groupName": {
            "type": "string",
            "description": "Display name for the group.",
            "nullable": true
          },
          "completedCount": {
            "type": "integer",
            "description": "Number of tasks completed in the window for this group.",
            "format": "int32"
          },
          "avgTurnaroundDays": {
            "type": "number",
            "description": "Average calendar days from planned start date to completion (negatives clamped to 0).",
            "format": "double"
          },
          "medianTurnaroundDays": {
            "type": "number",
            "description": "Median calendar days from planned start date to completion.",
            "format": "double"
          },
          "onTimePct": {
            "type": "number",
            "description": "Percentage of the group completed on or before its due date.",
            "format": "double"
          },
          "statutoryOnTimePct": {
            "type": "number",
            "description": "Percentage of the group's statutory sub-cohort completed on or before the statutory date.\nNull when no task in the group has a statutory deadline.",
            "format": "double",
            "nullable": true
          },
          "statutoryCount": {
            "type": "integer",
            "description": "Number of tasks in the group with a statutory due date - the denominator behind StatutoryOnTimePct.",
            "format": "int32"
          },
          "worstCaseDays": {
            "type": "integer",
            "description": "The slowest turnaround in the group, in days.",
            "format": "int32"
          },
          "worstTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "One row of the Service Delivery Turnaround breakdown table - the cohort aggregated for a\nsingle group (service, client, assignee, or completion month). Carries entity codes so the\nfrontend can deep-link into the filtered task list."
      },
      "ServiceDeliveryRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceDeliveryRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ServiceDeliveryStepsDto": {
        "type": "object",
        "properties": {
          "service": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "taskCount": {
            "type": "integer",
            "description": "Number of distinct workflow tasks in the cohort the step durations were derived from.",
            "format": "int32"
          },
          "totalAvgDays": {
            "type": "number",
            "description": "Average total step-covered days per task (client-wait + internal).",
            "format": "double"
          },
          "clientWaitAvgDays": {
            "type": "number",
            "description": "Average days per task spent in client-wait steps (waiting on the client to act).",
            "format": "double"
          },
          "internalAvgDays": {
            "type": "number",
            "description": "Average days per task spent in internal steps (practice-side time).",
            "format": "double"
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepBottleneckDto"
            },
            "description": "Per-step aggregates, in workflow order.",
            "nullable": true
          },
          "generatedAt": {
            "type": "string",
            "description": "UTC timestamp the drill-down was computed.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Step-level bottleneck drill-down for one billable service: per-step duration aggregates\nplus the client-wait vs internal split (\"is it us or the client\")."
      },
      "ServiceDeliverySummaryDto": {
        "type": "object",
        "properties": {
          "completedCount": {
            "type": "integer",
            "description": "Number of tasks completed in the window.",
            "format": "int32"
          },
          "avgTurnaroundDays": {
            "type": "number",
            "description": "Average calendar days from planned start date to completion (negatives clamped to 0).\nNull when the cohort is empty.",
            "format": "double",
            "nullable": true
          },
          "medianTurnaroundDays": {
            "type": "number",
            "description": "Median calendar days from planned start date to completion. Null when the cohort is empty.",
            "format": "double",
            "nullable": true
          },
          "onTimePct": {
            "type": "number",
            "description": "Percentage of the cohort completed on or before its due date. Null when the cohort is empty.",
            "format": "double",
            "nullable": true
          },
          "statutoryOnTimePct": {
            "type": "number",
            "description": "Percentage of the statutory sub-cohort (tasks with a statutory due date) completed on or\nbefore that date. Null when no task in the cohort has a statutory deadline.",
            "format": "double",
            "nullable": true
          },
          "statutoryCount": {
            "type": "integer",
            "description": "Size of the statutory sub-cohort - the denominator behind StatutoryOnTimePct.",
            "format": "int32"
          },
          "overdueCount": {
            "type": "integer",
            "description": "Open tasks (NotStarted/InProgress/Blocked) past their due date right now.\nA now-snapshot: respects the entity filters but ignores the date window.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Headline KPIs for the Service Delivery Turnaround report, computed over the completion\ncohort (tasks whose CompletedDate falls in the requested window)."
      },
      "ServiceImportJobDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying this import job.\nUse this code to poll for status via GET /{code}.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ImportJobStatus"
          },
          "fileName": {
            "type": "string",
            "description": "Original filename of the uploaded CSV file",
            "nullable": true
          },
          "totalItems": {
            "type": "integer",
            "description": "Total number of data rows to process (excluding header row).\nMay be null if the job hasn't started processing yet.",
            "format": "int32",
            "nullable": true
          },
          "processedItems": {
            "type": "integer",
            "description": "Number of rows that have been processed so far",
            "format": "int32"
          },
          "createdCount": {
            "type": "integer",
            "description": "Number of client billable service records created",
            "format": "int32"
          },
          "skippedCount": {
            "type": "integer",
            "description": "Number of rows skipped (client not found, service already assigned, etc.)",
            "format": "int32"
          },
          "errorCount": {
            "type": "integer",
            "description": "Number of rows with errors",
            "format": "int32"
          },
          "startedDate": {
            "type": "string",
            "description": "When the job started processing (UTC)",
            "format": "date-time",
            "nullable": true
          },
          "completedDate": {
            "type": "string",
            "description": "When the job completed processing (UTC)",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the import job was created (UTC)",
            "format": "date-time"
          },
          "notImportedDownloadUrl": {
            "type": "string",
            "description": "URL to download a CSV containing rows that were not imported.\nOnly available when status is Completed and there were errors or skipped rows.\nThis is a time-limited SAS URL that expires after 60 minutes.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents the current status and progress of a service import job.\nReturned when starting an import or polling for status."
      },
      "ServiceImportPreviewActionDto": {
        "type": "object",
        "properties": {
          "service": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "action": {
            "type": "string",
            "description": "What will happen: Create, Update, or Unchanged",
            "nullable": true
          },
          "price": {
            "type": "number",
            "description": "Price from the CSV. Null when the row has no price (the assignment is imported unpriced).",
            "format": "double",
            "nullable": true
          },
          "frequency": {
            "type": "string",
            "description": "Billing frequency from the CSV",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "Start date from the CSV",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "End date from the CSV",
            "nullable": true
          },
          "currentPrice": {
            "type": "number",
            "description": "Current price of the existing assignment (null for creates)",
            "format": "double",
            "nullable": true
          },
          "currentFrequency": {
            "type": "string",
            "description": "Current frequency of the existing assignment (null for creates)",
            "nullable": true
          },
          "currentStartDate": {
            "type": "string",
            "description": "Current start date of the existing assignment (null for creates)",
            "nullable": true
          },
          "currentEndDate": {
            "type": "string",
            "description": "Current end date of the existing assignment (null for creates)",
            "nullable": true
          },
          "autoInvoice": {
            "type": "boolean",
            "description": "AutoInvoice value from the CSV (null if column absent)",
            "nullable": true
          },
          "currentAutoInvoice": {
            "type": "boolean",
            "description": "Current AutoInvoice of the existing assignment (null for creates)",
            "nullable": true
          },
          "stage": {
            "type": "string",
            "description": "Service stage name from the CSV (null if column blank)",
            "nullable": true
          },
          "currentStage": {
            "type": "string",
            "description": "Current service stage name of the existing assignment (null for creates)",
            "nullable": true
          },
          "quantity": {
            "type": "number",
            "description": "Unit quantity from the CSV (null if column blank)",
            "format": "double",
            "nullable": true
          },
          "currentQuantity": {
            "type": "number",
            "description": "Current unit quantity of the existing assignment (null for creates)",
            "format": "double",
            "nullable": true
          },
          "managedBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "currentManagedBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "preparer": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "currentPreparer": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "reviewer": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "currentReviewer": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "Preview for a single service action within a client"
      },
      "ServiceImportPreviewClientDto": {
        "type": "object",
        "properties": {
          "client": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "csvClientName": {
            "type": "string",
            "description": "The client name as it appears in the CSV (used when client is not found)",
            "nullable": true
          },
          "error": {
            "type": "string",
            "description": "Error message if client could not be matched",
            "nullable": true
          },
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceImportPreviewActionDto"
            },
            "description": "Services that will be created, updated, or skipped for this client",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Preview for a single client row in the CSV"
      },
      "ServiceImportPreviewDto": {
        "type": "object",
        "properties": {
          "asyncJobCode": {
            "type": "string",
            "description": "Job code to pass to the confirm endpoint to execute the import",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "description": "Original filename",
            "nullable": true
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceImportPreviewClientDto"
            },
            "description": "Per-client breakdown of what will happen",
            "nullable": true
          },
          "totalClients": {
            "type": "integer",
            "description": "Total number of client rows in the CSV",
            "format": "int32"
          },
          "clientsFound": {
            "type": "integer",
            "description": "Number of clients matched to existing clients",
            "format": "int32"
          },
          "clientsNotFound": {
            "type": "integer",
            "description": "Number of client rows where no matching client was found",
            "format": "int32"
          },
          "servicesToCreate": {
            "type": "integer",
            "description": "Number of new service assignments that will be created",
            "format": "int32"
          },
          "servicesToUpdate": {
            "type": "integer",
            "description": "Number of existing service assignments that will be updated (values differ)",
            "format": "int32"
          },
          "servicesUnchanged": {
            "type": "integer",
            "description": "Number of existing service assignments that are unchanged and will be skipped",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Preview of what a service CSV import will do, returned before the user confirms."
      },
      "ServiceImportSource": {
        "enum": [
          "Unknown",
          "Native",
          "Engager",
          "BrightManager"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "ServicePackageDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this service package",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The name of the service package",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Description of what this package includes",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "Whether this package is archived (inactive)"
          },
          "usePackagePricing": {
            "type": "boolean",
            "description": "Whether this package uses a single package-level price instead of summing individual item prices"
          },
          "packagePrice": {
            "type": "number",
            "description": "The flat price for the entire package. Only present when UsePackagePricing is true.",
            "format": "double",
            "nullable": true
          },
          "packageBillingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "packageSetupFee": {
            "type": "number",
            "description": "Optional one-off setup fee for the package, billed once when the package is first invoiced.\nOnly used when UsePackagePricing is true. Null means no setup fee.",
            "format": "double",
            "nullable": true
          },
          "proposalContent": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "totalAnnualValue": {
            "type": "number",
            "description": "The total annual value of all services in this package",
            "format": "double"
          },
          "numberOfServices": {
            "type": "integer",
            "description": "The number of services in this package",
            "format": "int32"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServicePackageItemDto"
            },
            "description": "The services included in this package",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the package was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the package was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for service package information"
      },
      "ServicePackageDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServicePackageDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ServicePackageItemDto": {
        "type": "object",
        "properties": {
          "billableServiceCode": {
            "type": "string",
            "description": "The code of the billable service",
            "nullable": true
          },
          "billableServiceName": {
            "type": "string",
            "description": "The name of the billable service",
            "nullable": true
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "overridePricing": {
            "type": "boolean",
            "description": "Whether to override the standard pricing from the billable service"
          },
          "price": {
            "type": "number",
            "description": "The custom price to use when OverridePricing is true",
            "format": "double",
            "nullable": true
          },
          "pricingAnswers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Pre-answered pricing factors (key = factor description, value = selected option name)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for a service included in a service package"
      },
      "ServicePackageSortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "ServicePricingMode": {
        "enum": [
          "RevenueRange",
          "CustomTiers"
        ],
        "type": "string",
        "example": "RevenueRange"
      },
      "ServiceStatus": {
        "enum": [
          "Active",
          "Inactive",
          "Paused",
          "Proposed"
        ],
        "type": "string",
        "example": "Active"
      },
      "ServiceTimeContextDto": {
        "type": "object",
        "properties": {
          "serviceCode": {
            "type": "string",
            "description": "Service code",
            "nullable": true
          },
          "serviceName": {
            "type": "string",
            "description": "Service name",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "Client code",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "Client name",
            "nullable": true
          },
          "taskCode": {
            "type": "string",
            "description": "Task code",
            "nullable": true
          },
          "taskName": {
            "type": "string",
            "description": "Task name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The names behind the Service Time drill parameters. A part is null when the level doesn't\nreach it, or (task drill) when the task has no service."
      },
      "ServiceTimeLevel": {
        "enum": [
          "Service",
          "Client",
          "Task",
          "Step",
          "TeamMember",
          "Stage"
        ],
        "type": "string",
        "example": "Service"
      },
      "ServiceTimeReportDto": {
        "type": "object",
        "properties": {
          "level": {
            "$ref": "#/components/schemas/ServiceTimeLevel"
          },
          "context": {
            "$ref": "#/components/schemas/ServiceTimeContextDto"
          },
          "summary": {
            "$ref": "#/components/schemas/ServiceTimeSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/ServiceTimeRowDtoPagedResult"
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Service Time report: estimated vs actual time per service (\"we sold this for X hours —\ndid it take X?\"), computed from time entries attributed to services via their linked tasks.\nThe drill parameters pick the level: per service, client, task or workflow step, or per\nteam member."
      },
      "ServiceTimeRowDto": {
        "type": "object",
        "properties": {
          "groupCode": {
            "type": "string",
            "description": "The code of the group — a service, client, task or team member code. Null on workflow\nstep rows and catch-all rows.",
            "nullable": true
          },
          "groupName": {
            "type": "string",
            "description": "The display name of the group",
            "nullable": true
          },
          "groupKind": {
            "$ref": "#/components/schemas/ReportGroupKind"
          },
          "sectionName": {
            "type": "string",
            "description": "Workflow step rows only: the workflow group the step sits in",
            "nullable": true
          },
          "dueDate": {
            "type": "string",
            "description": "Task rows only: the task's due date, which tells apart recurring tasks sharing a name",
            "format": "date",
            "nullable": true
          },
          "estimatedMinutes": {
            "type": "integer",
            "description": "Summed effective estimates of the tasks the time was logged against — per task the\nsum of its non-omitted workflow step estimates, falling back to the task's own\nestimate when it has no step estimates. A step row carries its own estimate; a team\nmember row the estimates of the steps (or tasks) assigned to them. Null when nothing\nbehind the row has an estimate.",
            "format": "int32",
            "nullable": true
          },
          "totalMinutes": {
            "type": "integer",
            "description": "Total minutes logged against the group in the window",
            "format": "int32"
          },
          "entryCount": {
            "type": "integer",
            "description": "Number of time entries behind the total",
            "format": "int32"
          },
          "engagementCount": {
            "type": "integer",
            "description": "Number of distinct client-service engagements the time was logged against",
            "format": "int32"
          },
          "taskCount": {
            "type": "integer",
            "description": "Number of distinct tasks the time was logged against (the estimate is summed over these)",
            "format": "int32"
          },
          "varianceMinutes": {
            "type": "number",
            "description": "Total minutes minus the estimate — positive means over estimate.\nNull when no task behind the row has an estimate.",
            "format": "double",
            "nullable": true
          },
          "variancePct": {
            "type": "number",
            "description": "Variance as a percentage of the estimate — positive means over estimate.\nNull when no task behind the row has an estimate.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One Service Time breakdown row"
      },
      "ServiceTimeRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceTimeRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ServiceTimeSummaryDto": {
        "type": "object",
        "properties": {
          "totalMinutes": {
            "type": "integer",
            "description": "Total minutes logged in the window, within the scope",
            "format": "int32"
          },
          "attributedMinutes": {
            "type": "integer",
            "description": "Minutes attributable to a service (entry linked to a task that carries a service)",
            "format": "int32"
          },
          "unattributedMinutes": {
            "type": "integer",
            "description": "Minutes not attributable to any service — included so the breakdown reconciles with the total",
            "format": "int32"
          },
          "billableMinutes": {
            "type": "integer",
            "description": "Minutes marked billable in the window",
            "format": "int32"
          },
          "entryCount": {
            "type": "integer",
            "description": "Number of time entries in the window",
            "format": "int32"
          },
          "estimatedMinutes": {
            "type": "integer",
            "description": "Scoped only: the summed effective estimates of the tasks in scope. Null at the unscoped\nservice level (its total includes time with no service to estimate against), or when\nnothing in scope has an estimate.",
            "format": "int32",
            "nullable": true
          },
          "varianceMinutes": {
            "type": "number",
            "description": "Total minutes minus the estimate (positive means over). Null without an estimate.",
            "format": "double",
            "nullable": true
          },
          "variancePct": {
            "type": "number",
            "description": "Variance as a percentage of the estimate (positive means over). Null without an estimate.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Headline aggregates for the Service Time report, over the window narrowed to the drill\nscope: everything at the service level, else the service, client or task drilled into\n(or the service filtering the team member view), so the figures match the row drilled from"
      },
      "SetAllWorkflowStepsStatusRequest": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "cancelOutstandingRequests": {
            "type": "boolean",
            "description": "Also cancel what the steps being closed still have out with the client (the steps'\nOutstandingClientRequest): Draft or Open document requests, forms awaiting a response,\npending approval requests (retracting any e-signature bundle) and unanswered confirmation\nlinks. False leaves them live."
          }
        },
        "additionalProperties": false,
        "description": "Request to set every open step of a task's workflow to Completed or Skipped in one go,\nregardless of step dependencies. Omitted steps and steps already Completed or Skipped are left\nas they are."
      },
      "SetConversationTriageRequest": {
        "type": "object",
        "properties": {
          "setStatus": {
            "type": "boolean",
            "description": "Whether to change the status to SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.StatusCode"
          },
          "statusCode": {
            "maxLength": 100,
            "type": "string",
            "description": "An active email triage status code; required with SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.SetStatus",
            "nullable": true
          },
          "setAssignee": {
            "type": "boolean",
            "description": "Whether to change the assignee to SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.AssigneeCode"
          },
          "assigneeCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The tenant user code to assign the conversation to, who must be able to read the whole mailbox;\nnull unassigns it",
            "nullable": true
          },
          "notifyMeWhenDone": {
            "type": "boolean",
            "description": "With SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.SetAssignee: whether the caller, as the assigner, is told when someone else sets a Done status"
          },
          "silent": {
            "type": "boolean",
            "description": "A background change nobody is told about: no new assignee or assigner hears of it, and an assignee change keeps\nwho assigned the conversation and whether they hear when it is done as they were (so SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.NotifyMeWhenDone\nis ignored). For an assistant that takes a conversation while it works on it and then hands it back."
          },
          "setBringBack": {
            "type": "boolean",
            "description": "Whether to set the bring back to exactly SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.BringBackDate and SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.BringBackStatusCode\n(docs/features/EmailTriage/BRING-BACK-PLAN.md B8), with or without a status change. When false, a change of status\ntakes the new status's default bring back, if it has one, and otherwise clears any pending one."
          },
          "bringBackDate": {
            "type": "string",
            "description": "With SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.SetBringBack: the practice day to bring the conversation back on (at 08:00 UK time), today or\nlater; null removes the bring back",
            "format": "date",
            "nullable": true
          },
          "bringBackStatusCode": {
            "maxLength": 100,
            "type": "string",
            "description": "With SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.SetBringBack and a SodiumHQ.DTOs.EmailTriage.SetConversationTriageRequest.BringBackDate: the status to bring the conversation back to, an\nactive status that does not mean Done and is not the one the conversation is in",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Changes a conversation's triage status, its assignee, or both (docs/features/EmailTriage/PLAN.md D13).\nOnly the parts flagged are changed."
      },
      "SetDocumentsPortalVisibilityRequest": {
        "required": [
          "documentCodes",
          "visible"
        ],
        "type": "object",
        "properties": {
          "documentCodes": {
            "maxItems": 100,
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the documents to show or hide. Duplicates are ignored."
          },
          "visible": {
            "type": "boolean",
            "description": "True to make the documents visible in the client portal, false to hide them."
          }
        },
        "additionalProperties": false,
        "description": "Shows or hides one or more documents in the client portal.\nDocuments already in the requested state are unaffected."
      },
      "SetMtdAccountingTypeRequest": {
        "required": [
          "accountingType"
        ],
        "type": "object",
        "properties": {
          "accountingType": {
            "$ref": "#/components/schemas/HmrcAccountingType"
          }
        },
        "additionalProperties": false,
        "description": "Sets the accounting basis — cash or accruals — for one income source and tax year.\n            \nHMRC accept this during the tax year and up to the tax return; after that the year's basis is\nfixed. It changes how the year's figures are computed, so it belongs before the figures are\nprepared rather than after."
      },
      "SetMtdPeriodsOfAccountRequest": {
        "required": [
          "hasPeriodsOfAccount"
        ],
        "type": "object",
        "properties": {
          "hasPeriodsOfAccount": {
            "type": "boolean",
            "description": "True when the business has periods of account other than the tax year. HMRC require\nSodium.HmrcMtd.Product.Contracts.Dtos.SetMtdPeriodsOfAccountRequest.Periods when this is true and require it to be absent when false — sending the\ntwo out of step is refused."
          },
          "periods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PeriodOfAccount"
            },
            "description": "The periods themselves. Required when Sodium.HmrcMtd.Product.Contracts.Dtos.SetMtdPeriodsOfAccountRequest.HasPeriodsOfAccount is true.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Declares whether a self-employment income source draws its accounts to periods other than the\ntax year, and if so what those periods are.\n            \nA full replacement of the year's declaration, and HMRC require it before the tax return."
      },
      "SetMtdQuarterlyPeriodTypeRequest": {
        "required": [
          "periodType"
        ],
        "type": "object",
        "properties": {
          "periodType": {
            "$ref": "#/components/schemas/HmrcQuarterlyPeriodType"
          }
        },
        "additionalProperties": false,
        "description": "Elects standard (6 April) or calendar (1 April) quarterly reporting periods for one income\nsource and tax year. Deadlines are unchanged either way. The election must be made before the\ntax year's first quarterly update — it locks the moment one is submitted, until the next year."
      },
      "SetOrganizationRequest": {
        "type": "object",
        "properties": {
          "organizationId": {
            "type": "string",
            "description": "The organization ID to set",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to set organization for a third-party connection"
      },
      "SetPipelineStageStepConfigDto": {
        "type": "object",
        "properties": {
          "pipelineCode": {
            "type": "string",
            "description": "The code of the Pipeline whose stage should be set",
            "nullable": true
          },
          "stageCode": {
            "type": "string",
            "description": "The code of the PipelineStage to set on the client's pipeline card",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for SetPipelineStage workflow steps.\nSets the stage on the client's pipeline card when executed."
      },
      "SetPortalAccessRequest": {
        "type": "object",
        "properties": {
          "hasPortalAccess": {
            "type": "boolean",
            "description": "Whether the contact should have portal access."
          }
        },
        "additionalProperties": false,
        "description": "Request to grant or revoke portal access for a contact."
      },
      "SetSavedFilterMenuOrderRequest": {
        "required": [
          "codes"
        ],
        "type": "object",
        "properties": {
          "codes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the saved views in the order they should appear in the current user's menu"
          }
        },
        "additionalProperties": false,
        "description": "Request to set the order of the current user's saved-view menu entries"
      },
      "SetSavedFilterMenuRequest": {
        "type": "object",
        "properties": {
          "includeInMenu": {
            "type": "boolean",
            "description": "Whether the filter should appear in the current user's menu/quick access list"
          }
        },
        "additionalProperties": false,
        "description": "Request to set the current user's menu preference for a saved filter"
      },
      "SetServiceStageStepConfigDto": {
        "type": "object",
        "properties": {
          "billableServiceCode": {
            "type": "string",
            "description": "The code of the BillableService whose stage should be set",
            "nullable": true
          },
          "stageCode": {
            "type": "string",
            "description": "The code of the BillableServiceStage to set on the client's service",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for SetServiceStage workflow steps.\nSets the stage on the client's billable service when executed."
      },
      "SetTaxMonthRequest": {
        "required": [
          "taxMonthEnd"
        ],
        "type": "object",
        "properties": {
          "taxMonthEnd": {
            "type": "string",
            "description": "The 5th the tax month ends on, e.g. 2026-05-05 for 6 April to 5 May 2026 (any other day is a 400)",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "Sets the tax month a task is for (\"Change tax month\"). A CIS Manager step already under way keeps the month in\nits own state."
      },
      "SetupFeeBillingMoment": {
        "enum": [
          "OnAcceptance",
          "WithFirstInvoice"
        ],
        "type": "string",
        "example": "OnAcceptance"
      },
      "ShareOptionItem": {
        "type": "object",
        "properties": {
          "employerName": {
            "type": "string",
            "nullable": true
          },
          "employerRef": {
            "type": "string",
            "nullable": true
          },
          "schemePlanType": {
            "type": "string",
            "nullable": true
          },
          "dateOfOptionGrant": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "dateOfEvent": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "optionNotExercisedButConsiderationReceived": {
            "type": "boolean",
            "nullable": true
          },
          "amountOfConsiderationReceived": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "noOfSharesAcquired": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "classOfSharesAcquired": {
            "type": "string",
            "nullable": true
          },
          "exercisePrice": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountPaidForOption": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "marketValueOfSharesOnExcise": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "profitOnOptionExercised": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "employersNicPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxableAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SharesAwardedOrReceivedItem": {
        "type": "object",
        "properties": {
          "employerName": {
            "type": "string",
            "nullable": true
          },
          "employerRef": {
            "type": "string",
            "nullable": true
          },
          "schemePlanType": {
            "type": "string",
            "nullable": true
          },
          "dateSharesCeasedToBeSubjectToPlan": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "noOfShareSecuritiesAwarded": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "classOfShareAwarded": {
            "type": "string",
            "nullable": true
          },
          "dateSharesAwarded": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "sharesSubjectToRestrictions": {
            "type": "boolean",
            "nullable": true
          },
          "electionEnteredIgnoreRestrictions": {
            "type": "boolean",
            "nullable": true
          },
          "actualMarketValueOfSharesOnAward": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "unrestrictedMarketValueOfSharesOnAward": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "amountPaidForSharesOnAward": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "marketValueAfterRestrictionsLifted": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxableAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SicCode": {
        "enum": [
          "SIC01110",
          "SIC01120",
          "SIC01130",
          "SIC01140",
          "SIC01150",
          "SIC01160",
          "SIC01190",
          "SIC01210",
          "SIC01220",
          "SIC01230",
          "SIC01240",
          "SIC01250",
          "SIC01260",
          "SIC01270",
          "SIC01280",
          "SIC01290",
          "SIC01300",
          "SIC01410",
          "SIC01420",
          "SIC01430",
          "SIC01440",
          "SIC01450",
          "SIC01460",
          "SIC01470",
          "SIC01490",
          "SIC01500",
          "SIC01610",
          "SIC01621",
          "SIC01629",
          "SIC01630",
          "SIC01640",
          "SIC01700",
          "SIC02100",
          "SIC02200",
          "SIC02300",
          "SIC02400",
          "SIC03110",
          "SIC03120",
          "SIC03210",
          "SIC03220",
          "SIC05101",
          "SIC05102",
          "SIC05200",
          "SIC06100",
          "SIC06200",
          "SIC07100",
          "SIC07210",
          "SIC07290",
          "SIC08110",
          "SIC08120",
          "SIC08910",
          "SIC08920",
          "SIC08930",
          "SIC08990",
          "SIC09100",
          "SIC09900",
          "SIC10110",
          "SIC10120",
          "SIC10130",
          "SIC10200",
          "SIC10310",
          "SIC10320",
          "SIC10390",
          "SIC10410",
          "SIC10420",
          "SIC10511",
          "SIC10512",
          "SIC10519",
          "SIC10520",
          "SIC10611",
          "SIC10612",
          "SIC10620",
          "SIC10710",
          "SIC10720",
          "SIC10730",
          "SIC10810",
          "SIC10821",
          "SIC10822",
          "SIC10831",
          "SIC10832",
          "SIC10840",
          "SIC10850",
          "SIC10860",
          "SIC10890",
          "SIC10910",
          "SIC10920",
          "SIC11010",
          "SIC11020",
          "SIC11030",
          "SIC11040",
          "SIC11050",
          "SIC11060",
          "SIC11070",
          "SIC12000",
          "SIC13100",
          "SIC13200",
          "SIC13300",
          "SIC13910",
          "SIC13921",
          "SIC13922",
          "SIC13923",
          "SIC13931",
          "SIC13939",
          "SIC13940",
          "SIC13950",
          "SIC13960",
          "SIC13990",
          "SIC14110",
          "SIC14120",
          "SIC14131",
          "SIC14132",
          "SIC14141",
          "SIC14142",
          "SIC14190",
          "SIC14200",
          "SIC14310",
          "SIC14390",
          "SIC15110",
          "SIC15120",
          "SIC15200",
          "SIC16100",
          "SIC16210",
          "SIC16220",
          "SIC16230",
          "SIC16240",
          "SIC16290",
          "SIC17110",
          "SIC17120",
          "SIC17211",
          "SIC17219",
          "SIC17220",
          "SIC17230",
          "SIC17240",
          "SIC17290",
          "SIC18110",
          "SIC18121",
          "SIC18129",
          "SIC18130",
          "SIC18140",
          "SIC18201",
          "SIC18202",
          "SIC18203",
          "SIC19100",
          "SIC19201",
          "SIC19209",
          "SIC20110",
          "SIC20120",
          "SIC20130",
          "SIC20140",
          "SIC20150",
          "SIC20160",
          "SIC20170",
          "SIC20200",
          "SIC20301",
          "SIC20302",
          "SIC20411",
          "SIC20412",
          "SIC20420",
          "SIC20510",
          "SIC20520",
          "SIC20530",
          "SIC20590",
          "SIC20600",
          "SIC21100",
          "SIC21200",
          "SIC22110",
          "SIC22190",
          "SIC22210",
          "SIC22220",
          "SIC22230",
          "SIC22290",
          "SIC23110",
          "SIC23120",
          "SIC23130",
          "SIC23140",
          "SIC23190",
          "SIC23200",
          "SIC23310",
          "SIC23320",
          "SIC23410",
          "SIC23420",
          "SIC23430",
          "SIC23440",
          "SIC23490",
          "SIC23510",
          "SIC23520",
          "SIC23610",
          "SIC23620",
          "SIC23630",
          "SIC23640",
          "SIC23650",
          "SIC23690",
          "SIC23700",
          "SIC23910",
          "SIC23990",
          "SIC24100",
          "SIC24200",
          "SIC24310",
          "SIC24320",
          "SIC24330",
          "SIC24340",
          "SIC24410",
          "SIC24420",
          "SIC24430",
          "SIC24440",
          "SIC24450",
          "SIC24460",
          "SIC24510",
          "SIC24520",
          "SIC24530",
          "SIC24540",
          "SIC25110",
          "SIC25120",
          "SIC25210",
          "SIC25290",
          "SIC25300",
          "SIC25400",
          "SIC25500",
          "SIC25610",
          "SIC25620",
          "SIC25710",
          "SIC25720",
          "SIC25730",
          "SIC25910",
          "SIC25920",
          "SIC25930",
          "SIC25940",
          "SIC25990",
          "SIC26110",
          "SIC26120",
          "SIC26200",
          "SIC26301",
          "SIC26309",
          "SIC26400",
          "SIC26511",
          "SIC26512",
          "SIC26513",
          "SIC26514",
          "SIC26520",
          "SIC26600",
          "SIC26701",
          "SIC26702",
          "SIC26800",
          "SIC27110",
          "SIC27120",
          "SIC27200",
          "SIC27310",
          "SIC27320",
          "SIC27330",
          "SIC27400",
          "SIC27510",
          "SIC27520",
          "SIC27900",
          "SIC28110",
          "SIC28120",
          "SIC28131",
          "SIC28132",
          "SIC28140",
          "SIC28150",
          "SIC28210",
          "SIC28220",
          "SIC28230",
          "SIC28240",
          "SIC28250",
          "SIC28290",
          "SIC28301",
          "SIC28302",
          "SIC28410",
          "SIC28490",
          "SIC28910",
          "SIC28921",
          "SIC28922",
          "SIC28923",
          "SIC28930",
          "SIC28940",
          "SIC28950",
          "SIC28960",
          "SIC28990",
          "SIC29100",
          "SIC29201",
          "SIC29202",
          "SIC29203",
          "SIC29310",
          "SIC29320",
          "SIC30110",
          "SIC30120",
          "SIC30200",
          "SIC30300",
          "SIC30400",
          "SIC30910",
          "SIC30920",
          "SIC30990",
          "SIC31010",
          "SIC31020",
          "SIC31030",
          "SIC31090",
          "SIC32110",
          "SIC32120",
          "SIC32130",
          "SIC32200",
          "SIC32300",
          "SIC32401",
          "SIC32409",
          "SIC32500",
          "SIC32910",
          "SIC32990",
          "SIC33110",
          "SIC33120",
          "SIC33130",
          "SIC33140",
          "SIC33150",
          "SIC33160",
          "SIC33170",
          "SIC33190",
          "SIC33200",
          "SIC35110",
          "SIC35120",
          "SIC35130",
          "SIC35140",
          "SIC35210",
          "SIC35220",
          "SIC35230",
          "SIC35300",
          "SIC36000",
          "SIC37000",
          "SIC38110",
          "SIC38120",
          "SIC38210",
          "SIC38220",
          "SIC38310",
          "SIC38320",
          "SIC39000",
          "SIC41100",
          "SIC41201",
          "SIC41202",
          "SIC42110",
          "SIC42120",
          "SIC42130",
          "SIC42210",
          "SIC42220",
          "SIC42910",
          "SIC42990",
          "SIC43110",
          "SIC43120",
          "SIC43130",
          "SIC43210",
          "SIC43220",
          "SIC43290",
          "SIC43310",
          "SIC43320",
          "SIC43330",
          "SIC43341",
          "SIC43342",
          "SIC43390",
          "SIC43910",
          "SIC43991",
          "SIC43999",
          "SIC45111",
          "SIC45112",
          "SIC45190",
          "SIC45200",
          "SIC45310",
          "SIC45320",
          "SIC45400",
          "SIC46110",
          "SIC46120",
          "SIC46130",
          "SIC46140",
          "SIC46150",
          "SIC46160",
          "SIC46170",
          "SIC46180",
          "SIC46190",
          "SIC46210",
          "SIC46220",
          "SIC46230",
          "SIC46240",
          "SIC46310",
          "SIC46320",
          "SIC46330",
          "SIC46341",
          "SIC46342",
          "SIC46350",
          "SIC46360",
          "SIC46370",
          "SIC46380",
          "SIC46390",
          "SIC46410",
          "SIC46420",
          "SIC46431",
          "SIC46439",
          "SIC46440",
          "SIC46450",
          "SIC46460",
          "SIC46470",
          "SIC46480",
          "SIC46491",
          "SIC46499",
          "SIC46510",
          "SIC46520",
          "SIC46610",
          "SIC46620",
          "SIC46630",
          "SIC46640",
          "SIC46650",
          "SIC46660",
          "SIC46690",
          "SIC46711",
          "SIC46719",
          "SIC46720",
          "SIC46730",
          "SIC46740",
          "SIC46750",
          "SIC46760",
          "SIC46770",
          "SIC46900",
          "SIC47110",
          "SIC47190",
          "SIC47210",
          "SIC47220",
          "SIC47230",
          "SIC47240",
          "SIC47250",
          "SIC47260",
          "SIC47290",
          "SIC47300",
          "SIC47410",
          "SIC47421",
          "SIC47429",
          "SIC47430",
          "SIC47510",
          "SIC47520",
          "SIC47530",
          "SIC47540",
          "SIC47591",
          "SIC47599",
          "SIC47610",
          "SIC47620",
          "SIC47630",
          "SIC47640",
          "SIC47650",
          "SIC47710",
          "SIC47721",
          "SIC47722",
          "SIC47730",
          "SIC47741",
          "SIC47749",
          "SIC47750",
          "SIC47760",
          "SIC47770",
          "SIC47781",
          "SIC47782",
          "SIC47789",
          "SIC47791",
          "SIC47799",
          "SIC47810",
          "SIC47820",
          "SIC47890",
          "SIC47910",
          "SIC47990",
          "SIC49100",
          "SIC49200",
          "SIC49311",
          "SIC49319",
          "SIC49320",
          "SIC49390",
          "SIC49410",
          "SIC49420",
          "SIC49500",
          "SIC50100",
          "SIC50200",
          "SIC50300",
          "SIC50400",
          "SIC51101",
          "SIC51102",
          "SIC51210",
          "SIC51220",
          "SIC52101",
          "SIC52102",
          "SIC52103",
          "SIC52109",
          "SIC52211",
          "SIC52212",
          "SIC52213",
          "SIC52219",
          "SIC52220",
          "SIC52230",
          "SIC52241",
          "SIC52242",
          "SIC52243",
          "SIC52290",
          "SIC53100",
          "SIC53201",
          "SIC53202",
          "SIC55100",
          "SIC55201",
          "SIC55202",
          "SIC55209",
          "SIC55300",
          "SIC55900",
          "SIC56101",
          "SIC56102",
          "SIC56103",
          "SIC56210",
          "SIC56290",
          "SIC56301",
          "SIC56302",
          "SIC58110",
          "SIC58120",
          "SIC58130",
          "SIC58141",
          "SIC58142",
          "SIC58190",
          "SIC58210",
          "SIC58290",
          "SIC59111",
          "SIC59112",
          "SIC59113",
          "SIC59120",
          "SIC59131",
          "SIC59132",
          "SIC59133",
          "SIC59140",
          "SIC59200",
          "SIC60100",
          "SIC60200",
          "SIC61100",
          "SIC61200",
          "SIC61300",
          "SIC61900",
          "SIC62011",
          "SIC62012",
          "SIC62020",
          "SIC62030",
          "SIC62090",
          "SIC63110",
          "SIC63120",
          "SIC63910",
          "SIC63990",
          "SIC64110",
          "SIC64191",
          "SIC64192",
          "SIC64201",
          "SIC64202",
          "SIC64203",
          "SIC64204",
          "SIC64205",
          "SIC64209",
          "SIC64301",
          "SIC64302",
          "SIC64303",
          "SIC64304",
          "SIC64305",
          "SIC64306",
          "SIC64910",
          "SIC64921",
          "SIC64922",
          "SIC64929",
          "SIC64991",
          "SIC64992",
          "SIC64999",
          "SIC65110",
          "SIC65120",
          "SIC65201",
          "SIC65202",
          "SIC65300",
          "SIC66110",
          "SIC66120",
          "SIC66190",
          "SIC66210",
          "SIC66220",
          "SIC66290",
          "SIC66300",
          "SIC68100",
          "SIC68201",
          "SIC68202",
          "SIC68209",
          "SIC68310",
          "SIC68320",
          "SIC69101",
          "SIC69102",
          "SIC69109",
          "SIC69201",
          "SIC69202",
          "SIC69203",
          "SIC70100",
          "SIC70210",
          "SIC70221",
          "SIC70229",
          "SIC71111",
          "SIC71112",
          "SIC71121",
          "SIC71122",
          "SIC71129",
          "SIC71200",
          "SIC72110",
          "SIC72190",
          "SIC72200",
          "SIC73110",
          "SIC73120",
          "SIC73200",
          "SIC74100",
          "SIC74201",
          "SIC74202",
          "SIC74203",
          "SIC74209",
          "SIC74300",
          "SIC74901",
          "SIC74902",
          "SIC74909",
          "SIC75000",
          "SIC77110",
          "SIC77120",
          "SIC77210",
          "SIC77220",
          "SIC77291",
          "SIC77299",
          "SIC77310",
          "SIC77320",
          "SIC77330",
          "SIC77341",
          "SIC77342",
          "SIC77351",
          "SIC77352",
          "SIC77390",
          "SIC77400",
          "SIC78101",
          "SIC78109",
          "SIC78200",
          "SIC78300",
          "SIC79110",
          "SIC79120",
          "SIC79901",
          "SIC79909",
          "SIC80100",
          "SIC80200",
          "SIC80300",
          "SIC81100",
          "SIC81210",
          "SIC81221",
          "SIC81222",
          "SIC81223",
          "SIC81229",
          "SIC81291",
          "SIC81299",
          "SIC81300",
          "SIC82110",
          "SIC82190",
          "SIC82200",
          "SIC82301",
          "SIC82302",
          "SIC82911",
          "SIC82912",
          "SIC82920",
          "SIC82990",
          "SIC84110",
          "SIC84120",
          "SIC84130",
          "SIC84210",
          "SIC84220",
          "SIC84230",
          "SIC84240",
          "SIC84250",
          "SIC84300",
          "SIC85100",
          "SIC85200",
          "SIC85310",
          "SIC85320",
          "SIC85410",
          "SIC85421",
          "SIC85422",
          "SIC85510",
          "SIC85520",
          "SIC85530",
          "SIC85590",
          "SIC85600",
          "SIC86101",
          "SIC86102",
          "SIC86210",
          "SIC86220",
          "SIC86230",
          "SIC86900",
          "SIC87100",
          "SIC87200",
          "SIC87300",
          "SIC87900",
          "SIC88100",
          "SIC88910",
          "SIC88990",
          "SIC90010",
          "SIC90020",
          "SIC90030",
          "SIC90040",
          "SIC91011",
          "SIC91012",
          "SIC91020",
          "SIC91030",
          "SIC91040",
          "SIC92000",
          "SIC93110",
          "SIC93120",
          "SIC93130",
          "SIC93191",
          "SIC93199",
          "SIC93210",
          "SIC93290",
          "SIC94110",
          "SIC94120",
          "SIC94200",
          "SIC94910",
          "SIC94920",
          "SIC94990",
          "SIC95110",
          "SIC95120",
          "SIC95210",
          "SIC95220",
          "SIC95230",
          "SIC95240",
          "SIC95250",
          "SIC95290",
          "SIC96010",
          "SIC96020",
          "SIC96030",
          "SIC96040",
          "SIC96090",
          "SIC97000",
          "SIC98000",
          "SIC98100",
          "SIC98200",
          "SIC99000",
          "SIC99999"
        ],
        "type": "string",
        "example": "SIC01110"
      },
      "SignatureRequestStatus": {
        "enum": [
          "Pending",
          "Viewed",
          "Signed",
          "Rejected",
          "Finalised",
          "Cancelled",
          "Draft"
        ],
        "type": "string",
        "example": "Pending"
      },
      "SkippedConversationDto": {
        "type": "object",
        "properties": {
          "configCode": {
            "type": "string",
            "description": "The mailbox's email config code",
            "nullable": true
          },
          "conversationId": {
            "type": "string",
            "description": "The provider's thread id",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "description": "Why: `triageOff` (the mailbox is gone or has triage off), `noAccess` (the caller does not read the whole\nmailbox), `hidden` (the owner's exclusion rules hide it from the caller, or from the colleague being\nassigned), `assigneeNotAllowed` (the person being assigned cannot be given this mailbox's conversations),\n`changed` (its status changed while the bring back was being set) or `failed` (the write failed)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A conversation a bulk triage change left as it was"
      },
      "SmtpEncryption": {
        "enum": [
          "Auto",
          "Ssl",
          "Tls"
        ],
        "type": "string",
        "description": "SMTP encryption methods",
        "example": "Auto"
      },
      "SmtpSettingsRequest": {
        "required": [
          "host",
          "port"
        ],
        "type": "object",
        "properties": {
          "host": {
            "minLength": 1,
            "type": "string",
            "description": "SMTP server host"
          },
          "port": {
            "type": "integer",
            "description": "SMTP server port",
            "format": "int32"
          },
          "encryption": {
            "$ref": "#/components/schemas/SmtpEncryption"
          },
          "requiresAuthentication": {
            "type": "boolean",
            "description": "Indicates whether the SMTP server requires authentication\nIf false, the connection will be made without authentication (open relay)"
          },
          "username": {
            "type": "string",
            "description": "SMTP username (required if RequiresAuthentication = true)",
            "nullable": true
          },
          "password": {
            "type": "string",
            "description": "SMTP password (required if RequiresAuthentication = true)",
            "nullable": true
          },
          "timeout": {
            "type": "integer",
            "description": "Connection timeout in milliseconds",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "SMTP settings for API requests"
      },
      "SmtpSettingsResponseDto": {
        "type": "object",
        "properties": {
          "host": {
            "type": "string",
            "description": "SMTP server host",
            "nullable": true
          },
          "port": {
            "type": "integer",
            "description": "SMTP server port",
            "format": "int32"
          },
          "encryption": {
            "$ref": "#/components/schemas/SmtpEncryption"
          },
          "requiresAuthentication": {
            "type": "boolean",
            "description": "Indicates whether the SMTP server requires authentication"
          },
          "username": {
            "type": "string",
            "description": "SMTP username",
            "nullable": true
          },
          "hasPassword": {
            "type": "boolean",
            "description": "Whether a password is configured (true/false, actual password never returned)"
          },
          "timeout": {
            "type": "integer",
            "description": "Connection timeout in milliseconds",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "SMTP settings response (passwords are never returned)"
      },
      "SodiumProduct": {
        "enum": [
          "CisManager",
          "Mtd"
        ],
        "type": "string",
        "example": "CisManager"
      },
      "SplitMailboxMessageResponse": {
        "type": "object",
        "properties": {
          "splitEmailCount": {
            "type": "integer",
            "description": "1 when the email moved to a conversation of its own, 0 when it was already alone in its conversation",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The result of splitting an email out of its conversation"
      },
      "StaffEmailOwnerDto": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "description": "The address, lower case",
            "nullable": true
          },
          "userCode": {
            "type": "string",
            "description": "The team member's code",
            "nullable": true
          },
          "userName": {
            "type": "string",
            "description": "The team member's name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A member of staff an email address belongs to"
      },
      "StageFigureRequest": {
        "required": [
          "figure",
          "stageCode"
        ],
        "type": "object",
        "properties": {
          "stageCode": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string"
          },
          "figure": {
            "maximum": 10000000,
            "minimum": 0.01,
            "type": "number",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "A stage's figure in a by-stage standard: minutes for hours, pounds for the fee. A stage left out\nhas no figure."
      },
      "StandardFeeMode": {
        "enum": [
          "None",
          "Fixed",
          "ByStage",
          "EachClientsPrice"
        ],
        "type": "string",
        "example": "None"
      },
      "StandardHoursMode": {
        "enum": [
          "None",
          "FollowStepEstimates",
          "Fixed",
          "ByStage"
        ],
        "type": "string",
        "example": "None"
      },
      "StartClientBooksConnectionRequest": {
        "required": [
          "platform"
        ],
        "type": "object",
        "properties": {
          "platform": {
            "maxLength": 50,
            "minLength": 1,
            "type": "string",
            "description": "The accounting platform to authorise against (e.g. \"Xero\", \"QuickBooks\", \"FreeAgent\")."
          },
          "redirectUrl": {
            "maxLength": 400,
            "type": "string",
            "description": "Where to send the browser once the platform has redirected back. A literal `[code]` in\nthe URL is replaced with the resulting connection's code.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Starts a fresh authorisation against a client's own accounting software."
      },
      "StartDateType": {
        "enum": [
          "SpecificDate",
          "WeekDay",
          "MonthDay",
          "ClientDate",
          "RelativeToDue",
          "Sequence"
        ],
        "type": "string",
        "example": "SpecificDate"
      },
      "StartHmrcBulkRequestDto": {
        "required": [
          "authorisationType",
          "clients"
        ],
        "type": "object",
        "properties": {
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          },
          "clients": {
            "maxItems": 1000,
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HmrcBulkRequestClientInputDto"
            },
            "description": "The clients to send, with any details the practice filled in for them."
          },
          "hmrcCredentialCode": {
            "maxLength": 100,
            "type": "string",
            "description": "Code of the HMRC credential set that makes the requests. Null uses the default set.",
            "nullable": true
          },
          "authCodeEntryDelayDays": {
            "maximum": 60,
            "minimum": 0,
            "type": "integer",
            "description": "How many days after each request to email the client the link they use to enter the posted code. 0 sends it as\nsoon as HMRC accept the request. **Null means the clients are not invited** and the practice enters the codes.",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Requests one 64-8 authorisation from HMRC for many clients at once"
      },
      "StartRunningTimerRequest": {
        "type": "object",
        "properties": {
          "description": {
            "maxLength": 1000,
            "type": "string",
            "description": "What the time is being spent on",
            "nullable": true
          },
          "isBillable": {
            "type": "boolean",
            "description": "Whether the logged time will be billable — carried onto the entry when the timer stops"
          },
          "clientCode": {
            "type": "string",
            "description": "The code of the client the time relates to (optional)",
            "nullable": true
          },
          "taskItemCode": {
            "type": "string",
            "description": "The code of the task the time relates to (optional)",
            "nullable": true
          },
          "workflowGroupNumber": {
            "type": "integer",
            "description": "The group number of the workflow step the time relates to (optional; requires\nTaskItemCode and WorkflowStepNumber) — carried onto the entry when the timer stops",
            "format": "int32",
            "nullable": true
          },
          "workflowStepNumber": {
            "type": "integer",
            "description": "The step number of the workflow step the time relates to (optional; requires\nTaskItemCode and WorkflowGroupNumber) — carried onto the entry when the timer stops",
            "format": "int32",
            "nullable": true
          },
          "timeEntryCode": {
            "type": "string",
            "description": "The code of one of the caller's existing time entries to add the timed work to when\nthe timer stops (optional). Omit to log a new entry.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to start the calling user's timer, or update the details of the one\nalready running (the start time is preserved on update)"
      },
      "StartSubscriptionBillingRequest": {
        "type": "object",
        "properties": {
          "billingAddress": {
            "$ref": "#/components/schemas/BillingAddress"
          }
        },
        "additionalProperties": false,
        "description": "Request to start subscription billing for a tenant.\nName, billing contact, and tenant are auto-populated from context."
      },
      "StatutoryDateConfigDto": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/StatutoryDateType"
          },
          "date": {
            "type": "string",
            "description": "The first Statutory date of the cycle, year included. Required when Type is SpecificDate and the\nStatutory date drives the schedule (Schedule.Basis is StatutoryDate): the cycle starts here and\nnothing is created before it, and FixedMonth/FixedDay are taken from it. Omitted otherwise, when\nFixedMonth/FixedDay (DD/MM annual) are used instead.",
            "format": "date-time",
            "nullable": true
          },
          "fixedMonth": {
            "type": "integer",
            "description": "Month (1-12). Required when Type is SpecificDate and Statutory does not drive the schedule; otherwise taken from Date.",
            "format": "int32",
            "nullable": true
          },
          "fixedDay": {
            "type": "integer",
            "description": "Day of month (1-31). Required when Type is SpecificDate and Statutory does not drive the schedule; otherwise taken from Date. Clamped to last day of month at projection time.",
            "format": "int32",
            "nullable": true
          },
          "dayOfMonth": {
            "type": "integer",
            "description": "Nth day of month (1-31). Required when Type is DayOfMonth. Clamped to last day for shorter months.",
            "format": "int32",
            "nullable": true
          },
          "clientDateSourceType": {
            "$ref": "#/components/schemas/ClientDateSourceType"
          },
          "clientDateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "customFieldDefinitionCode": {
            "type": "string",
            "description": "Custom field code. Required when Type is ClientKeyDate and ClientDateSourceType is CustomField.",
            "nullable": true
          },
          "customFieldDefinitionLabel": {
            "type": "string",
            "description": "Custom field label. Populated in responses only.",
            "nullable": true
          },
          "timing": {
            "$ref": "#/components/schemas/DaysBeforeOrAfter"
          },
          "offsetDays": {
            "type": "integer",
            "description": "Days portion of the offset relative to the client date. Required when Type is ClientKeyDate.",
            "format": "int32",
            "nullable": true
          },
          "offsetMonths": {
            "type": "integer",
            "description": "Months portion of the offset relative to the client date. Optional alongside OffsetDays - e.g.\n\"Year End + 9 months + 1 day\" for CT payment. Must be >= 0 when set; direction comes from Timing.",
            "format": "int32",
            "nullable": true
          },
          "sequenceSeedDate": {
            "type": "string",
            "description": "The first Statutory date of the repeating cycle (the sequence seed). Required when Type is\nSequence; the Statutory advances from here through Recurrence.Sequence, wrapping indefinitely.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for the projected StatutoryDueDate on tasks created from a recurring task.\nDifferent properties are required based on the Type value:\n- None: no statutory date is set.\n- SpecificDate: Date (a full date) when Statutory drives the schedule, otherwise FixedMonth + FixedDay\n  (DD/MM annual; invalid days clamped to end-of-month).\n- ClientKeyDate: ClientDateSourceType + Timing + OffsetDays (OffsetMonths optional), plus\n  ClientDateType (KeyDate source) or CustomFieldDefinitionCode (CustomField source).\n- DayOfMonth: DayOfMonth (1-31; clamped to last day for shorter months).\n- Sequence: SequenceSeedDate + Recurrence.Sequence (Statutory advances through the repeating\n  periods from the seed) - requires TaskDateBasis=StatutoryDate."
      },
      "StatutoryDateType": {
        "enum": [
          "None",
          "SpecificDate",
          "ClientKeyDate",
          "DayOfMonth",
          "Sequence"
        ],
        "type": "string",
        "example": "None"
      },
      "StepBottleneckDto": {
        "type": "object",
        "properties": {
          "groupName": {
            "type": "string",
            "description": "The workflow group (section) the step belongs to - lets the UI divide the step table\ninto the same sections the workflow shows.",
            "nullable": true
          },
          "stepName": {
            "type": "string",
            "description": "Step name (snapshotted per task; renamed steps aggregate separately).",
            "nullable": true
          },
          "stepType": {
            "$ref": "#/components/schemas/WorkflowStepType"
          },
          "stage": {
            "$ref": "#/components/schemas/ClientBillableServiceStageDto"
          },
          "isClientWait": {
            "type": "boolean",
            "description": "True when the step completes on a client action - its elapsed time is client-wait time\n(DocumentRequest, DocumentApproval, ClientConfirmation, SendDataForm). False = internal time."
          },
          "count": {
            "type": "integer",
            "description": "Number of step instances (completed or skipped) aggregated into this row.",
            "format": "int32"
          },
          "avgDurationDays": {
            "type": "number",
            "description": "Average elapsed days from the previous step's completion to this step's completion.",
            "format": "double"
          },
          "skippedCount": {
            "type": "integer",
            "description": "How many of the instances were skipped rather than completed. Skipped steps stay in the\naverages (their elapsed time is real time the task sat there) - this column makes that visible.",
            "format": "int32"
          },
          "avgChaseCount": {
            "type": "number",
            "description": "Average number of chases sent for this step (client-facing steps only; 0 elsewhere).",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Duration aggregates for one workflow step across the cohort's workflow tasks for a single\nbillable service. A step's duration runs from the previous step's completion (or the task's\nactual start for the first step) to its own completion, so it includes idle time waiting\nfor the step to begin - the \"where do tasks sit\" measure."
      },
      "StorageLocationDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Platform-specific identifier for this group (e.g. SharePoint site ID).",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name of the group (e.g. \"Client A Site\").",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StorageLocationItemDto"
            },
            "description": "Selectable storage locations within this group.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A group of selectable storage locations available through a connection\n(e.g. a SharePoint site containing document libraries)."
      },
      "StorageLocationItemDto": {
        "type": "object",
        "properties": {
          "driveId": {
            "type": "string",
            "description": "Platform-specific drive identifier. Pass as driveId when browsing folders or assigning client folders.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name of the storage location.",
            "nullable": true
          },
          "webUrl": {
            "type": "string",
            "description": "Direct link to the storage location in the provider's web UI.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A selectable storage location (e.g. a document library / drive) that can be assigned to a client."
      },
      "StorageType": {
        "enum": [
          "AzureBlob",
          "External"
        ],
        "type": "string",
        "example": "AzureBlob"
      },
      "StringSegment": {
        "type": "object",
        "properties": {
          "buffer": {
            "type": "string",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32",
            "readOnly": true
          },
          "length": {
            "type": "integer",
            "format": "int32",
            "readOnly": true
          },
          "value": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "hasValue": {
            "type": "boolean",
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "StructuredBuildingAllowanceItem": {
        "type": "object",
        "properties": {
          "amount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "firstYear": {
            "$ref": "#/components/schemas/StructuredBuildingFirstYear"
          },
          "building": {
            "$ref": "#/components/schemas/BuildingDetails"
          }
        },
        "additionalProperties": false
      },
      "StructuredBuildingFirstYear": {
        "type": "object",
        "properties": {
          "qualifyingDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "qualifyingAmountExpenditure": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "StudentLoanBenefitInKind": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "payrolledBenefits": {
            "type": "number",
            "format": "double"
          }
        },
        "additionalProperties": false
      },
      "StudentLoanDeductions": {
        "type": "object",
        "properties": {
          "uglDeductionAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "pglDeductionAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SubmissionStampResponse": {
        "type": "object",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/HmrcSubmissionKind"
          },
          "action": {
            "$ref": "#/components/schemas/HmrcSubmissionAction"
          },
          "reference": {
            "type": "string",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "nullable": true
          },
          "performedBy": {
            "type": "string",
            "nullable": true
          },
          "performedDate": {
            "type": "string",
            "format": "date-time"
          },
          "correlationId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SubmitDocumentRequestRequest": {
        "type": "object",
        "properties": {
          "comments": {
            "type": "string",
            "description": "Comments to include with the submission. Required if no documents are attached.",
            "nullable": true
          },
          "itemNumbers": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "For a request with items: the items to send. Leave empty to send every item with something\nsaved on it. Ignored for a request without items.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for submitting a document request response"
      },
      "SubmitInvoiceRequest": {
        "required": [
          "billingDate"
        ],
        "type": "object",
        "properties": {
          "billingDate": {
            "type": "string",
            "description": "The billing date of the projected submission to create and push",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "Request body for submitting an invoice for a specific billing date"
      },
      "SubmitLetterAuthCodeRequest": {
        "required": [
          "authorisationCode",
          "authorisationType"
        ],
        "type": "object",
        "properties": {
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          },
          "authorisationCode": {
            "maxLength": 20,
            "minLength": 1,
            "type": "string",
            "description": "The authorisation code from the letter HMRC posted to the client"
          }
        },
        "additionalProperties": false,
        "description": "Request to submit the authorisation code received by post from HMRC (letter-based flow)."
      },
      "SubmitMtdBsasAdjustmentsRequest": {
        "required": [
          "incomeSourceType",
          "taxYear"
        ],
        "type": "object",
        "properties": {
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "taxYear": {
            "maxLength": 7,
            "minLength": 1,
            "type": "string",
            "description": "The tax year the summary belongs to, in HMRC's format, e.g. 2025-26."
          },
          "selfEmployment": {
            "$ref": "#/components/schemas/SelfEmploymentBsasAdjustmentInputs"
          },
          "ukProperty": {
            "$ref": "#/components/schemas/UkPropertyBsasAdjustmentInputs"
          },
          "foreignProperty": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForeignPropertyBsasAdjustmentEntry"
            },
            "description": "The foreign property adjustments, one entry per let. Required when the income source is a\nforeign property business.\n            \nThere is no whole-business entry: a foreign adjustment always names the let it applies to,\nby country code up to 2025-26 and by registered property id from 2026-27.",
            "nullable": true
          },
          "zeroAdjustments": {
            "type": "boolean",
            "description": "Declares the summary needs no adjustment at all. Only true is meaningful, and it can never be\nsent alongside figures — HMRC reject that combination.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Submits accounting adjustments against one adjustable summary.\n            \nValues are **deltas** to the summarised figures — an amount to add or subtract, not the figure\nit should become. HMRC accept adjustments once per summary, so getting this wrong means\ntriggering a fresh summary rather than correcting this one."
      },
      "SubmitMtdQuarterlyUpdateRequest": {
        "required": [
          "isDeclarationConfirmed"
        ],
        "type": "object",
        "properties": {
          "isDeclarationConfirmed": {
            "type": "boolean",
            "description": "Confirmation that the figures are correct to the best of the submitter's knowledge. Must be\ntrue — this is recorded against the submission as the practice's evidence of the declaration."
          }
        },
        "additionalProperties": false,
        "description": "Sends a prepared quarterly update to HMRC. The declaration is part of the request because it is\nmade at the moment of sending, by the person sending it."
      },
      "SubmitMtdTaxReturnRequest": {
        "required": [
          "calculationId"
        ],
        "type": "object",
        "properties": {
          "calculationId": {
            "maxLength": 60,
            "minLength": 1,
            "type": "string",
            "description": "The calculation being declared — the one the review names. HMRC must have produced it for\nthis tax year as an intent to finalise, or as an intent to amend when\nSodium.HmrcMtd.Product.Contracts.Dtos.SubmitMtdTaxReturnRequest.DeclarationType is a confirmed amendment; crossing the two files against the\nwrong figures and is refused before HMRC is called."
          },
          "declarationType": {
            "$ref": "#/components/schemas/HmrcFinalDeclarationType"
          },
          "isDeclarationAgreed": {
            "type": "boolean",
            "description": "Whether the filer has read and agreed HMRC's declaration statement.\n            \n⚠ <strong>A gate, not a record.</strong> HMRC require the software itself to withhold\nsubmission until the declaration has been read and agreed — it is the one readiness rule that\nis enforced rather than advised, and a submission without it is refused before HMRC is\ncalled."
          },
          "declarationVersion": {
            "maxLength": 60,
            "type": "string",
            "description": "The version of the declaration wording that was displayed and agreed to, from the review's\n`declaration.statementVersion`.\n            \nChecked, not just recorded: a form left open across a change of HMRC's wording is refused, so\na client's return can never be filed on a declaration nobody read.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Sends a client's tax return to HMRC.\n            \n⚠ <strong>The highest-stakes call in the product, and the one filing that is not idempotent.</strong>\nHMRC create something that cannot be re-stated, so a second send for a year is the worst\noutcome there is. A submission whose outcome is unknown is settled by reconciling it against\nHMRC's own record, never by sending again."
      },
      "SubscriptionDiscountDto": {
        "type": "object",
        "properties": {
          "discountCodeValue": {
            "type": "string",
            "description": "The discount code that was redeemed.",
            "nullable": true
          },
          "discountPercent": {
            "type": "integer",
            "description": "The percentage discount being applied.",
            "format": "int32"
          },
          "startDate": {
            "type": "string",
            "description": "When the discount started.",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "When the discount expires. Null means permanent.",
            "format": "date-time",
            "nullable": true
          },
          "hasBeenBilled": {
            "type": "boolean",
            "description": "Whether this discount has been applied to at least one billing cycle.\nIf true, the discount cannot be re-applied after removal."
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for an active subscription discount on a tenant."
      },
      "SubscriptionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this subscription",
            "nullable": true
          },
          "package": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "pricingTier": {
            "$ref": "#/components/schemas/PricingTierDto"
          },
          "monthlyPricePence": {
            "type": "integer",
            "description": "The monthly price in pence",
            "format": "int32"
          },
          "startDate": {
            "type": "string",
            "description": "When the subscription started",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "When the subscription ends (null for perpetual subscriptions)",
            "format": "date-time",
            "nullable": true
          },
          "comment": {
            "type": "string",
            "description": "Optional comment about the subscription",
            "nullable": true
          },
          "isFreeTrial": {
            "type": "boolean",
            "description": "Whether this subscription is a free trial"
          },
          "pendingSubscription": {
            "$ref": "#/components/schemas/SubscriptionDto"
          },
          "discount": {
            "$ref": "#/components/schemas/SubscriptionDiscountDto"
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for subscription information (excludes internal IDs)"
      },
      "SubscriptionPricePreviewDto": {
        "type": "object",
        "properties": {
          "package": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "pricingTier": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "monthlyPricePence": {
            "type": "integer",
            "description": "The base monthly price in pence before any discounts.",
            "format": "int32"
          },
          "discountPercent": {
            "type": "integer",
            "description": "The active discount percentage applied (0 if no discount).",
            "format": "int32"
          },
          "discountedMonthlyPricePence": {
            "type": "integer",
            "description": "The discounted monthly price in pence after applying any active discount.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Preview of the subscription price for a package based on the tenant's active client count."
      },
      "SuggestedEmailAddressDto": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "description": "The address, lower case",
            "nullable": true
          },
          "platformName": {
            "type": "string",
            "description": "The note taker connected with it (e.g. \"Granola\")",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A note-taker account that may be one of the team member's other addresses"
      },
      "SystemFolderType": {
        "enum": [
          "None",
          "Inbox",
          "Sent",
          "Drafts",
          "Junk",
          "Trash",
          "Archive",
          "Outbox",
          "GmailCategory",
          "GmailPromotionalCategory",
          "OutsideFolderTree"
        ],
        "type": "string",
        "description": "Identifies which provider-system folder a row represents.\nNone (0, the default) means the row is a user-created folder or a Gmail user label.",
        "example": "None"
      },
      "SystemRole": {
        "enum": [
          "Admin",
          "StandardUser",
          "Viewer"
        ],
        "type": "string",
        "example": "Admin"
      },
      "SystemRolePermissionsDto": {
        "type": "object",
        "properties": {
          "systemRole": {
            "$ref": "#/components/schemas/SystemRole"
          },
          "permissions": {
            "type": "object",
            "properties": {
              "Tasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Users": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Clients": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Contacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientContacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Reports": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Settings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ApiKeys": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Roles": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ServicePackages": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "RecurringTasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Workflows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ThirdPartyConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ContentBlocks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDetails": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DesignThemes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Templates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Engagements": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CustomFields": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Subscription": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientPortalSettings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DocumentRequests": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Billing": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientEmailRules": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Mailbox": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Teams": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DataForms": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "KanbanBoards": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBilling": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailBroadcasts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeTracking": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Pipelines": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "WorkingPatterns": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalIncomeTax": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalTaxReturn": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooksConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BookkeepingHealth": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CostRates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ProductAccounts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Messaging": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeOff": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailTriage": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "JobBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "OutboundWebhooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeOverrides": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              }
            },
            "additionalProperties": false,
            "description": "The capabilities granted per entity, already intersected with the tenant's package —\na grant on an entity the package excludes is inert, so it is omitted rather than\npromising access the user would never get. Entities granting nothing are omitted too.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A built-in system role and the capabilities it grants per entity, as they apply within\nthis tenant. Mirrors the shape of SodiumHQ.DTOs.Role.RoleDto.Permissions so the two can be\nrendered by the same permission grid."
      },
      "TaskBudgetDto": {
        "type": "object",
        "properties": {
          "period": {
            "$ref": "#/components/schemas/BudgetCycleProgressDto"
          },
          "taskLoggedMinutes": {
            "type": "integer",
            "description": "Minutes logged on this task (all users; the caller's own when restricted to their own time)",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A task's budget period and how much of the logged time is on the task itself."
      },
      "TaskBudgetSummaryDto": {
        "type": "object",
        "properties": {
          "budgetMinutes": {
            "type": "integer",
            "description": "The hours budget of the task's period, in minutes",
            "format": "int32"
          },
          "loggedMinutes": {
            "type": "integer",
            "description": "The minutes logged to the job in the period",
            "format": "int32"
          },
          "hoursStatus": {
            "$ref": "#/components/schemas/BudgetStatus"
          }
        },
        "additionalProperties": false,
        "description": "A task's period budget for the task list's Budget column: totals only. For a caller restricted to\ntheir own time, LoggedMinutes is their own and there is no status."
      },
      "TaskCategoryDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this task category",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the task category",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying task categories",
            "format": "int32"
          },
          "color": {
            "type": "string",
            "description": "The color associated with this task category",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A grouping used to classify tasks"
      },
      "TaskCategoryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskCategoryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TaskCategorySortField": {
        "enum": [
          "SortOrder",
          "Name"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "TaskClientMatchSummaryDto": {
        "type": "object",
        "properties": {
          "matchedClientCount": {
            "type": "integer",
            "description": "Number of distinct client names that matched an existing client",
            "format": "int32"
          },
          "unmatchedClientCount": {
            "type": "integer",
            "description": "Number of distinct client names with no matching client",
            "format": "int32"
          },
          "unmatchedRowCount": {
            "type": "integer",
            "description": "Number of task rows whose client name didn't match",
            "format": "int32"
          },
          "unmatchedClientNames": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The unmatched client names (capped at 50)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "How a foreign task export's client names matched against existing clients.\nUnmatched names still convert — the native import flags them for review."
      },
      "TaskCsvConversionAnalysisDto": {
        "type": "object",
        "properties": {
          "source": {
            "$ref": "#/components/schemas/TaskImportSource"
          },
          "totalRows": {
            "type": "integer",
            "description": "Number of task rows in the file.",
            "format": "int32"
          },
          "assignees": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DetectedAssigneeDto"
            },
            "description": "The distinct assignee names in the file, for mapping to tenant users.",
            "nullable": true
          },
          "progressValues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DetectedProgressValueDto"
            },
            "description": "The distinct task progress values in the file, for mapping to task statuses.",
            "nullable": true
          },
          "clientMatchSummary": {
            "$ref": "#/components/schemas/TaskClientMatchSummaryDto"
          }
        },
        "additionalProperties": false,
        "description": "Result of analysing a foreign task CSV: the detected source plus the assignees and\nprogress values needing mapping, and how the file's client names matched."
      },
      "TaskDateBasis": {
        "enum": [
          "Any",
          "StartDate",
          "DueDate",
          "StatutoryDate",
          "CompletedDate"
        ],
        "type": "string",
        "example": "Any"
      },
      "TaskDateSummaryDto": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "The date the tasks fall on, per the query's dateBasis",
            "format": "date"
          },
          "totalCount": {
            "type": "integer",
            "description": "Total number of tasks on this date, before the per-date cap is applied",
            "format": "int32"
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskItemDto"
            },
            "description": "The first tasks for this date in stable order, capped at the request's perDateLimit.\nNextSteps is not populated on summary responses.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One date's slice of a task date summary: the first tasks on that date plus the\ntotal number of tasks the date holds. Dates with no tasks are omitted from responses."
      },
      "TaskFocusConfigDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier within the tenant",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskFocusConfigItemDto"
            },
            "description": "The saved task filter items displayed in the focus panel",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the config was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the config was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a user's task focus panel configuration"
      },
      "TaskFocusConfigItemDto": {
        "type": "object",
        "properties": {
          "savedTaskFilter": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "label": {
            "type": "string",
            "description": "Optional custom label for this item in the focus panel",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Sort order for display in the focus panel",
            "format": "int32"
          },
          "color": {
            "type": "string",
            "description": "Optional color for visual styling in the focus panel",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a single item in the task focus panel configuration"
      },
      "TaskHistoryEventType": {
        "enum": [
          "TaskCreated",
          "TaskStatusChanged",
          "TaskAssigneeChanged",
          "StepStatusChanged",
          "StepAssigneeChanged",
          "TaskAutomationChanged",
          "TaskChecklistItemChanged",
          "StepChecklistItemChanged"
        ],
        "type": "string",
        "example": "TaskCreated"
      },
      "TaskImportResultDto": {
        "type": "object",
        "properties": {
          "createdCount": {
            "type": "integer",
            "description": "Number of tasks created",
            "format": "int32",
            "readOnly": true
          },
          "updatedCount": {
            "type": "integer",
            "description": "Number of existing tasks updated",
            "format": "int32",
            "readOnly": true
          },
          "failedCount": {
            "type": "integer",
            "description": "Number of selected rows that failed to import",
            "format": "int32",
            "readOnly": true
          },
          "notesCreated": {
            "type": "integer",
            "description": "Number of task notes created from the Notes column",
            "format": "int32"
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskImportRowResultDto"
            },
            "description": "Per-row outcomes, in selection order",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of a task CSV import"
      },
      "TaskImportRowDto": {
        "type": "object",
        "properties": {
          "rowId": {
            "type": "string",
            "description": "Stable key for this row within the file: the native Code, or a synthetic \"row-{n}\"\nfor rows without a code",
            "nullable": true
          },
          "action": {
            "type": "string",
            "description": "What importing this row will do: \"Create\", \"Update\" (row whose Code matches\nan existing task) or \"Skip\" (unusable row — see SkipReason)",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The task name",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The task description",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "startDate": {
            "type": "string",
            "description": "The start date: the file's value, or min(today, due date) when the file has none.\nNull only for skipped rows without a usable due date.",
            "format": "date",
            "nullable": true
          },
          "dueDate": {
            "type": "string",
            "description": "The due date; null when missing from the file (the row is skipped unless overridden)",
            "format": "date",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "The start time: the file's value, or 09:00 when the file has none",
            "format": "time"
          },
          "dueTime": {
            "type": "string",
            "description": "The due time: the file's value, or 09:00 when the file has none",
            "format": "time"
          },
          "clientName": {
            "type": "string",
            "description": "The client name from the file; null when the row has no client",
            "nullable": true
          },
          "clientMatched": {
            "type": "boolean",
            "description": "Whether the client name resolved to an existing client (exact case-insensitive match,\nwith a \"Surname, Forename\" flip retry). True for rows without a client name."
          },
          "assignedUserName": {
            "type": "string",
            "description": "The assigned user name from the file; null when unassigned",
            "nullable": true
          },
          "assignedUserMatched": {
            "type": "boolean",
            "description": "Whether the assigned user name resolved to a tenant user. True for unassigned rows.\nAn unresolved name imports as unassigned (unless overridden in the selection)."
          },
          "assignedUserCode": {
            "type": "string",
            "description": "The code of the matched assigned user; null when unmatched or unassigned",
            "nullable": true
          },
          "hasNotes": {
            "type": "boolean",
            "description": "Whether the row carries notes text that will become a task note on import"
          },
          "isDuplicate": {
            "type": "boolean",
            "description": "Whether a create row matches an existing task on name, primary client and due date —\nimporting it would produce a near-duplicate"
          },
          "defaultSelected": {
            "type": "boolean",
            "description": "Whether the row should be pre-ticked in the review grid"
          },
          "skipReason": {
            "type": "string",
            "description": "Why the row cannot be imported (e.g. \"Missing task name\", \"Invalid Due Date\"); null for usable rows",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single task parsed from an uploaded task CSV, ready for user review.\nReturned by the analyze endpoint; the RowId is the key used in the import selections."
      },
      "TaskImportRowResultDto": {
        "type": "object",
        "properties": {
          "rowId": {
            "type": "string",
            "description": "The RowId from the import selection",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The task name from the row",
            "nullable": true
          },
          "action": {
            "type": "string",
            "description": "What the import did with the row: \"Create\", \"Update\" or \"Skip\"",
            "nullable": true
          },
          "success": {
            "type": "boolean",
            "description": "Whether the row imported successfully"
          },
          "taskCode": {
            "type": "string",
            "description": "The code of the created or updated task",
            "nullable": true
          },
          "error": {
            "type": "string",
            "description": "Why the row failed, when Success is false",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of importing a single task CSV row"
      },
      "TaskImportSource": {
        "enum": [
          "Unknown",
          "Native",
          "BrightManager"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "TaskItemDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier within the tenant",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The name of the task",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The description of the task. Returned by single-task endpoints only; list endpoints omit it.",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "isProjected": {
            "type": "boolean",
            "description": "Whether this task is projected (computed on the fly, not yet saved) or materialised (a saved task)"
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes.\nFalse keeps the task's own estimate."
          },
          "effectiveTimeEstimateMinutes": {
            "type": "integer",
            "description": "The estimate the task is planned and reported against: WorkflowStepEstimateMinutes when the\ntask has a workflow and UseWorkflowTimeEstimate is set, otherwise TimeEstimateMinutes.\nComputed, so it stays right when list paths fill WorkflowStepEstimateMinutes after mapping.",
            "format": "int32",
            "nullable": true,
            "readOnly": true
          },
          "startDate": {
            "type": "string",
            "description": "When the task starts",
            "format": "date"
          },
          "dueDate": {
            "type": "string",
            "description": "When the task is due",
            "format": "date"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day on SodiumHQ.DTOs.TaskItems.TaskItemDto.StartDate, in the practice's local time.",
            "format": "time"
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day on SodiumHQ.DTOs.TaskItems.TaskItemDto.DueDate, in the practice's local time.",
            "format": "time"
          },
          "isOverdue": {
            "type": "boolean",
            "description": "Indicates if the task is overdue (DueDate is before today and status is not Completed or Skipped)",
            "readOnly": true
          },
          "statutoryDueDate": {
            "type": "string",
            "description": "The statutory due date for compliance tasks (if applicable)",
            "format": "date",
            "nullable": true
          },
          "taxMonthEnd": {
            "type": "string",
            "description": "The 5th the tax month this task is for ends on, or null. Names the period in the task's emails and documents\nin place of the start date, and is the month its CIS Manager steps work on; editing the due date does not\nchange it.",
            "format": "date",
            "nullable": true
          },
          "originalStartDate": {
            "type": "string",
            "description": "The start date this task was originally projected for, set once at materialisation and\nnever changed afterwards. Null for tasks that did not come from a recurring task.\nIdentifies an occurrence across both materialisation and later rescheduling.",
            "format": "date",
            "nullable": true
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientRefDto"
            },
            "description": "The clients this task is associated with",
            "nullable": true
          },
          "primaryClient": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "clientManager": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "clientPartner": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "clientAssociate": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "servicePreparer": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "serviceReviewer": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When the task was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the task was last updated",
            "format": "date-time",
            "nullable": true
          },
          "clientBillableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "stage": {
            "$ref": "#/components/schemas/ClientBillableServiceStageDto"
          },
          "clientPipeline": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "recurringTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflow": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "category": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflowSteps": {
            "type": "integer",
            "description": "The total number of workflow steps for this task",
            "format": "int32",
            "nullable": true
          },
          "workflowStepsComplete": {
            "type": "integer",
            "description": "The number of workflow steps completed for this task",
            "format": "int32",
            "nullable": true
          },
          "isAutomationDisabled": {
            "type": "boolean",
            "description": "True when automation is switched off: the system never starts a workflow step on this\ntask. Staff can still run, complete, skip and reassign steps by hand."
          },
          "automationDisabledDate": {
            "type": "string",
            "description": "When automation was switched off. Null while automation is on.",
            "format": "date-time",
            "nullable": true
          },
          "automationDisabledByUserName": {
            "type": "string",
            "description": "Who switched automation off. Null means Sodium switched it off automatically.",
            "nullable": true
          },
          "workflowStepEstimateMinutes": {
            "type": "integer",
            "description": "Summed estimated minutes of the task's non-omitted workflow steps. Null when the\ntask has no workflow or none of its steps carry an estimate. See\nEffectiveTimeEstimateMinutes for the estimate actually in force.",
            "format": "int32",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this task",
            "nullable": true
          },
          "latestNoteContent": {
            "type": "string",
            "description": "The most recent note/comment on this task",
            "nullable": true
          },
          "latestNoteDate": {
            "type": "string",
            "description": "When the most recent note was created",
            "format": "date-time",
            "nullable": true
          },
          "budget": {
            "$ref": "#/components/schemas/TaskBudgetSummaryDto"
          },
          "workflowStepDetails": {
            "$ref": "#/components/schemas/WorkflowStepDetailsDto"
          },
          "nextSteps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NextStepDto"
            },
            "description": "The task's currently-executable workflow steps (dependencies met, not complete, not\nomitted), in group/step order. Includes auto-execute steps (flagged). Always empty for\nCompleted/Skipped tasks. Populated on list endpoints for main task rows; null on\nworkflow-step rows, projected tasks, and single-task responses.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A task, either standalone or a workflow step (with parent task context)"
      },
      "TaskItemDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskItemDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TaskItemHistoryEventDto": {
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "string",
            "description": "When the change happened (UTC)",
            "format": "date-time"
          },
          "eventType": {
            "$ref": "#/components/schemas/TaskHistoryEventType"
          },
          "stepName": {
            "type": "string",
            "description": "The name of the workflow step the event relates to. Null for task-level events.",
            "nullable": true
          },
          "isAutomationDisabled": {
            "type": "boolean",
            "description": "For an automation change, whether automation ended up switched off",
            "nullable": true
          },
          "checklistItemText": {
            "type": "string",
            "description": "The text of the checklist item that was ticked or unticked (checklist events only)",
            "nullable": true
          },
          "isChecklistItemCompleted": {
            "type": "boolean",
            "description": "For a checklist event, whether the item ended up ticked",
            "nullable": true
          },
          "fromStatus": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "toStatus": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "fromAssigneeUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "fromAssigneeTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "toAssigneeUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "toAssigneeTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "stage": {
            "$ref": "#/components/schemas/ClientBillableServiceStageDto"
          },
          "changedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "changedByClientName": {
            "type": "string",
            "description": "Display name of the external (client) actor that made the change — the contact\nname resolved at write time, falling back to their email. Null for staff/system changes.",
            "nullable": true
          },
          "changedByType": {
            "$ref": "#/components/schemas/AuditUserType"
          }
        },
        "additionalProperties": false,
        "description": "A single event in a task's history timeline — a status, assignee, automation or checklist\nchange on the task itself or one of its workflow steps."
      },
      "TaskItemNoteSortField": {
        "enum": [
          "Date",
          "UpdatedDate"
        ],
        "type": "string",
        "example": "Date"
      },
      "TaskItemSortField": {
        "enum": [
          "Name",
          "DueDate",
          "StartDate",
          "Category",
          "ClientName",
          "AssignedUser",
          "StatutoryDueDate",
          "Stage",
          "TimeInStage",
          "ClientManager",
          "ClientPartner",
          "ClientAssociate",
          "Status",
          "Service",
          "Team",
          "CreatedDate",
          "UpdatedDate",
          "ServicePreparer",
          "ServiceReviewer"
        ],
        "type": "string",
        "example": "Name"
      },
      "TaskItemStatus": {
        "enum": [
          "NotStarted",
          "InProgress",
          "Blocked",
          "Completed",
          "Skipped"
        ],
        "type": "string",
        "example": "NotStarted"
      },
      "TaskSettingsDto": {
        "type": "object",
        "properties": {
          "hideOmittedWorkflowSteps": {
            "type": "boolean",
            "description": "Whether workflow steps and step groups a condition has omitted are hidden on a task. When off\n(the default) they show as a muted \"Omitted\" line with the reason."
          }
        },
        "additionalProperties": false,
        "description": "Practice-wide settings for tasks."
      },
      "TaskStartConfigDto": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/StartDateType"
          },
          "interval": {
            "$ref": "#/components/schemas/RelativeIntervalDto"
          },
          "weekDayPatterns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WeekDayPatternDto"
            },
            "description": "Positional weekday patterns. Required when Type is MonthDay.\nExample: [{ Position: \"First\", Day: \"Monday\" }, { Position: \"Last\", Day: \"Friday\" }]",
            "nullable": true
          },
          "daysOfMonth": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Days of month (1-31). Used when Type is SpecificDate.\nExample: [1, 15] for 1st and 15th",
            "nullable": true
          },
          "day": {
            "$ref": "#/components/schemas/WeekDayType"
          },
          "clientDateSourceType": {
            "$ref": "#/components/schemas/ClientDateSourceType"
          },
          "clientDateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "customFieldDefinitionCode": {
            "type": "string",
            "description": "The code of the custom field definition. Required when Type is ClientDate and ClientDateSourceType is CustomField.\nOnly DATE-type custom fields are valid.",
            "nullable": true
          },
          "customFieldDefinitionLabel": {
            "type": "string",
            "description": "The label of the custom field definition. Populated in responses only.",
            "nullable": true
          },
          "timing": {
            "$ref": "#/components/schemas/DaysBeforeOrAfter"
          },
          "offsetDays": {
            "type": "integer",
            "description": "The number of days before or after the client date.\nUsed when Type is ClientDate and Timing is DaysBefore or DaysAfter.\nPaired with OffsetMonths for composite offsets like \"1 month + 7 days\".",
            "format": "int32",
            "nullable": true
          },
          "offsetMonths": {
            "type": "integer",
            "description": "The number of months before or after the client date. Paired with OffsetDays. NULL when no\nmonths portion is needed. Used when Type is ClientDate.",
            "format": "int32",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "Specific start date. Used when Type is SpecificDate.\nThis is when the recurring task should first start generating tasks.",
            "format": "date-time",
            "nullable": true
          },
          "sequenceSeedDate": {
            "type": "string",
            "description": "The first Start date of the repeating pattern (the cycle seed). Required when Type is\nSequence; pairs with Recurrence.Sequence exactly as on the Due and Statutory sides.",
            "format": "date-time",
            "nullable": true
          },
          "holidayAdjustment": {
            "$ref": "#/components/schemas/HolidayAdjustment"
          },
          "time": {
            "type": "string",
            "description": "Time of day stamped onto every projected Start date. Omit for 09:00; always populated in\nresponses.",
            "format": "time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for when a recurring task should start.\nDifferent properties are required based on the Type value:\n- SpecificDate: Date specifies the start date seed\n- WeekDay: Day specifies which day of the week to run on, Date the day the cycle counts from\n- MonthDay: WeekDayPatterns specifies positional patterns like \"First Monday\"\n- ClientDate: ClientDateType (or CustomFieldDefinitionCode), Timing, OffsetDays, OffsetMonths\n- RelativeToDue: Start derives from Due via Interval (Due-driven mode)"
      },
      "TaskSummaryDto": {
        "type": "object",
        "properties": {
          "notStarted": {
            "type": "integer",
            "description": "Count of tasks that are not started",
            "format": "int32"
          },
          "inProgress": {
            "type": "integer",
            "description": "Count of tasks that are in progress",
            "format": "int32"
          },
          "blocked": {
            "type": "integer",
            "description": "Count of tasks that are blocked",
            "format": "int32"
          },
          "completed": {
            "type": "integer",
            "description": "Count of tasks that are completed",
            "format": "int32"
          },
          "total": {
            "type": "integer",
            "description": "Total count of all tasks",
            "format": "int32",
            "readOnly": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for task summary by status"
      },
      "TaskTemplateDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "billableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate."
          },
          "dueDateOffsetDays": {
            "type": "integer",
            "description": "Days after the creation date for the default task due date",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day stamped onto the start date of the created task.",
            "format": "time"
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day stamped onto the due date of the created task.",
            "format": "time"
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "assignedUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflow": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "category": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this task template",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this template is active (inactive templates are hidden when creating tasks)"
          }
        },
        "additionalProperties": false,
        "description": "DTO for one-off task templates, exposing only codes and enums (never DB IDs)."
      },
      "TaskTemplateDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskTemplateDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TaskTemplateSortField": {
        "enum": [
          "Name",
          "DueDateOffsetDays"
        ],
        "type": "string",
        "example": "Name"
      },
      "TaskTokens": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The task's name. Usage: {{ Task.Name }}",
            "nullable": true
          },
          "code": {
            "type": "string",
            "description": "The task's code. Usage: {{ Task.Code }}",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "The task's start date. Usage: {{ Task.StartDate }}",
            "format": "date",
            "nullable": true
          },
          "dueDate": {
            "type": "string",
            "description": "The task's due date — the internal deadline the practice works to. Usage: {{ Task.DueDate }}",
            "format": "date",
            "nullable": true
          },
          "statutoryDueDate": {
            "type": "string",
            "description": "The statutory deadline behind the task (Companies House, HMRC), where the task has one.\nUsage: {{ Task.StatutoryDueDate }}",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The task a piece of content is being produced from, exposed as {{ Task.* }}.\n            \nOnly populated where a task is genuinely behind the render — a workflow step's email, or a task\nor step description being materialised. Everywhere else (broadcasts, ad-hoc client emails,\ndocument templates, signatures) the whole namespace is left null, so the tokens render blank\nrather than quietly showing another task's dates.\n            \nValues are DateOnly so Fluid renders them in the tenant's short date format by default and the\nformatDate filter works natively: {{ Task.DueDate | formatDate: \"long\" }}."
      },
      "TaskWorkloadSummaryDto": {
        "type": "object",
        "properties": {
          "overdue": {
            "type": "integer",
            "description": "Open tasks (Not Started, In Progress, or Blocked) due before today",
            "format": "int32"
          },
          "dueToday": {
            "type": "integer",
            "description": "Open tasks due today",
            "format": "int32"
          },
          "dueThisWeek": {
            "type": "integer",
            "description": "Open tasks due this week",
            "format": "int32"
          },
          "inProgress": {
            "type": "integer",
            "description": "Tasks currently In Progress, regardless of due date",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The standard workload buckets for a scope (user, team, or whole practice): how many\nopen tasks are overdue, due today, due this week, and in progress."
      },
      "TaxCalculation": {
        "type": "object",
        "properties": {
          "calculationId": {
            "type": "string",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "nullable": true
          },
          "calculationType": {
            "type": "string",
            "nullable": true
          },
          "requestedBy": {
            "type": "string",
            "nullable": true
          },
          "requestedTimestamp": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "calculationTimestamp": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "periodFrom": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "periodTo": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "totals": {
            "$ref": "#/components/schemas/TaxCalculationTotals"
          },
          "endOfYearEstimate": {
            "$ref": "#/components/schemas/TaxCalculationEndOfYearEstimate"
          },
          "messages": {
            "$ref": "#/components/schemas/TaxCalculationMessages"
          },
          "hasErrors": {
            "type": "boolean",
            "readOnly": true
          },
          "isComplete": {
            "type": "boolean",
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "TaxCalculationEndOfYearEstimate": {
        "type": "object",
        "properties": {
          "totalEstimatedIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalTaxableIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "incomeTaxAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "nic2": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "nic4": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalNicAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalAllowancesAndDeductions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalTaxDeducted": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "incomeTaxNicAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "cgtAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "incomeTaxNicAndCgtAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxCalculationMessage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "text": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxCalculationMessages": {
        "type": "object",
        "properties": {
          "info": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxCalculationMessage"
            },
            "nullable": true
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxCalculationMessage"
            },
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxCalculationMessage"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxCalculationTotals": {
        "type": "object",
        "properties": {
          "totalIncomeTaxAndNicsDue": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalIncomeTaxNicsCharged": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalTaxDeducted": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalIncomeTaxAndNicsAndCgt": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxLiabilityAdjustments": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "carryBackLossesDecrease": {
            "$ref": "#/components/schemas/CarryBackLossesDecrease"
          },
          "taxRefundedOrSetOff": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxMonthChoice": {
        "enum": [
          "Previous",
          "Current",
          "Next"
        ],
        "type": "string",
        "example": "Previous"
      },
      "TaxReturnBlocker": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "reference": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxReturnDeclaration": {
        "type": "object",
        "properties": {
          "statement": {
            "type": "string",
            "nullable": true
          },
          "statementVersion": {
            "type": "string",
            "nullable": true
          },
          "isReady": {
            "type": "boolean"
          },
          "blockers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxReturnBlocker"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxReturnIncomeSource": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "nullable": true
          },
          "typeOfBusiness": {
            "type": "string",
            "nullable": true
          },
          "tradingName": {
            "type": "string",
            "nullable": true
          },
          "isCurrent": {
            "type": "boolean"
          },
          "obligations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ObligationPeriod"
            },
            "nullable": true
          },
          "configuration": {
            "$ref": "#/components/schemas/TaxYearIncomeSourceConfiguration"
          },
          "selfEmploymentPosition": {
            "$ref": "#/components/schemas/SelfEmploymentCumulativeSummary"
          },
          "ukPropertyPosition": {
            "$ref": "#/components/schemas/UkPropertyCumulativeSummary"
          },
          "foreignPropertyPosition": {
            "$ref": "#/components/schemas/ForeignPropertyCumulativeSummary"
          },
          "selfEmploymentAnnual": {
            "$ref": "#/components/schemas/SelfEmploymentAnnualSubmission"
          },
          "ukPropertyAnnual": {
            "$ref": "#/components/schemas/UkPropertyAnnualSubmission"
          },
          "foreignPropertyAnnual": {
            "$ref": "#/components/schemas/ForeignPropertyAnnualSubmission"
          },
          "adjustableSummaries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BsasSummaryInfo"
            },
            "nullable": true
          },
          "lossesAndClaims": {
            "$ref": "#/components/schemas/LossesAndClaims"
          }
        },
        "additionalProperties": false
      },
      "TaxReturnStatus": {
        "enum": [
          "Unknown",
          "Submitting",
          "Submitted",
          "Failed"
        ],
        "type": "string",
        "example": "Unknown"
      },
      "TaxReturnSubmissionResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "nino": {
            "type": "string",
            "nullable": true
          },
          "taxYear": {
            "type": "string",
            "nullable": true
          },
          "calculationId": {
            "type": "string",
            "nullable": true
          },
          "declarationType": {
            "$ref": "#/components/schemas/HmrcFinalDeclarationType"
          },
          "status": {
            "$ref": "#/components/schemas/TaxReturnStatus"
          },
          "submittedBy": {
            "type": "string",
            "nullable": true
          },
          "submittedDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "declarationVersion": {
            "type": "string",
            "nullable": true
          },
          "hmrcCorrelationId": {
            "type": "string",
            "nullable": true
          },
          "failureReason": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxYearIncomeSourceConfiguration": {
        "type": "object",
        "properties": {
          "accountingType": {
            "$ref": "#/components/schemas/HmrcAccountingType"
          },
          "periodsOfAccount": {
            "$ref": "#/components/schemas/PeriodsOfAccountResponse"
          },
          "lateAccountingDateRule": {
            "$ref": "#/components/schemas/LateAccountingDateRuleResponse"
          },
          "supportsPeriodsOfAccount": {
            "type": "boolean"
          },
          "supportsLateAccountingDateRule": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TaxYearOtherIncomeResponse": {
        "type": "object",
        "properties": {
          "taxYear": {
            "type": "string",
            "nullable": true
          },
          "unavailableAreas": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "ukDividends": {
            "$ref": "#/components/schemas/UkDividendsIncome"
          },
          "foreignDividends": {
            "$ref": "#/components/schemas/DividendsIncome"
          },
          "savingsAccounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxYearSavingsAccount"
            },
            "nullable": true
          },
          "otherSavings": {
            "$ref": "#/components/schemas/OtherSavingsIncome"
          },
          "employments": {
            "$ref": "#/components/schemas/EmploymentsList"
          },
          "nonPayeEmploymentIncome": {
            "$ref": "#/components/schemas/NonPayeEmploymentIncome"
          },
          "otherEmploymentIncome": {
            "$ref": "#/components/schemas/OtherEmploymentIncome"
          },
          "investmentReliefs": {
            "$ref": "#/components/schemas/InvestmentReliefs"
          },
          "otherReliefs": {
            "$ref": "#/components/schemas/OtherReliefs"
          },
          "foreignReliefs": {
            "$ref": "#/components/schemas/ForeignReliefs"
          },
          "pensionsReliefs": {
            "$ref": "#/components/schemas/PensionsReliefs"
          },
          "charitableGiving": {
            "$ref": "#/components/schemas/CharitableGivingReliefs"
          },
          "otherCapitalGains": {
            "$ref": "#/components/schemas/OtherCapitalGains"
          },
          "residentialDisposals": {
            "$ref": "#/components/schemas/CgtResidentialDisposals"
          },
          "stamps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubmissionStampResponse"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxYearReturnResponse": {
        "type": "object",
        "properties": {
          "taxYear": {
            "type": "string",
            "nullable": true
          },
          "unavailableParts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "incomeSources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxReturnIncomeSource"
            },
            "nullable": true
          },
          "otherIncome": {
            "$ref": "#/components/schemas/TaxYearOtherIncomeResponse"
          },
          "calculation": {
            "$ref": "#/components/schemas/TaxCalculation"
          },
          "broughtForwardLosses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BroughtForwardLoss"
            },
            "nullable": true
          },
          "lossClaims": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LossClaim"
            },
            "nullable": true
          },
          "liabilityAdjustments": {
            "$ref": "#/components/schemas/TaxLiabilityAdjustments"
          },
          "supportsLiabilityAdjustments": {
            "type": "boolean"
          },
          "declaration": {
            "$ref": "#/components/schemas/TaxReturnDeclaration"
          },
          "submissions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxReturnSubmissionResponse"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TaxYearSavingsAccount": {
        "type": "object",
        "properties": {
          "savingsAccountId": {
            "type": "string",
            "nullable": true
          },
          "accountName": {
            "type": "string",
            "nullable": true
          },
          "interest": {
            "$ref": "#/components/schemas/SavingsAccountInterest"
          }
        },
        "additionalProperties": false
      },
      "TeamDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this team",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the team",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional description of the team's purpose",
            "nullable": true
          },
          "iconName": {
            "type": "string",
            "description": "Optional Lucide icon name for visual identification",
            "nullable": true
          },
          "color": {
            "type": "string",
            "description": "Optional hex color for visual identification",
            "nullable": true
          },
          "canBeAssignedToTasks": {
            "type": "boolean",
            "description": "Whether this team can be assigned to tasks"
          },
          "canBeAssignedToClients": {
            "type": "boolean",
            "description": "Whether this team can be assigned to clients"
          },
          "members": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The members of this team",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a team"
      },
      "TeamDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TeamDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TeamSortField": {
        "enum": [
          "Name"
        ],
        "type": "string",
        "example": "Name"
      },
      "TeamTimeCategoryDto": {
        "type": "object",
        "properties": {
          "categoryCode": {
            "type": "string",
            "description": "The category code, or null for the uncategorised bucket",
            "nullable": true
          },
          "categoryName": {
            "type": "string",
            "description": "The category name, or \"No category\" for the uncategorised bucket",
            "nullable": true
          },
          "loggedMinutes": {
            "type": "integer",
            "description": "Minutes this member logged in the category — zero when they logged none, so every row\ncarries the full column set and the table lines up",
            "format": "int32"
          },
          "billableMinutes": {
            "type": "integer",
            "description": "Of those, the minutes marked billable",
            "format": "int32"
          },
          "entryCount": {
            "type": "integer",
            "description": "Number of time entries behind the minutes",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One member's minutes in one task category"
      },
      "TeamTimeCategoryTotalDto": {
        "type": "object",
        "properties": {
          "categoryCode": {
            "type": "string",
            "description": "The category code, or null for the uncategorised bucket",
            "nullable": true
          },
          "categoryName": {
            "type": "string",
            "description": "The category name, or \"No category\" for time logged against a task in no category, a\nservice linked directly, or nothing at all",
            "nullable": true
          },
          "loggedMinutes": {
            "type": "integer",
            "description": "Minutes everyone logged in this category over the window",
            "format": "int32"
          },
          "billableMinutes": {
            "type": "integer",
            "description": "Of those, the minutes marked billable",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One task category in the report's breakdown, with what the whole team logged against it"
      },
      "TeamTimeDayDto": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "The date logged against",
            "format": "date"
          },
          "minutes": {
            "type": "integer",
            "description": "Minutes logged on that date",
            "format": "int32"
          },
          "isWorkingDay": {
            "type": "boolean",
            "description": "True when this member's working pattern expects time on this date — so an empty day\nthey were meant to work reads differently from a day they never work. Bank holidays\nare never working days"
          },
          "expectedMinutes": {
            "type": "integer",
            "description": "Minutes the member's pattern expects on this date, so a day can be read against its\nown target rather than an average",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One day's logged minutes within a Team Time row"
      },
      "TeamTimeReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/TeamTimeSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/TeamTimeRowDtoPagedResult"
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TeamTimeCategoryTotalDto"
            },
            "description": "The task categories anyone logged time against in the window, in the practice's own\ncategory order with the uncategorised bucket last. This is the column set for the\nper-member category breakdown — it covers the whole cohort rather than the current\npage, so paging can't make a column appear and disappear. Categories nobody logged\nagainst are left out entirely.",
            "nullable": true
          },
          "teams": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TeamTimeTeamTotalDto"
            },
            "description": "Each team's totals over its members in the cohort, by team name. A member of two teams\ncounts in both",
            "nullable": true
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Team Time report: how many hours each team member logged over a period, against how\nmany they were expected to log. Answers \"is everyone hitting their week?\" without checking\nperson by person — under-logging (gaps, sickness) and over-logging (quiet overtime) both\nshow as variance."
      },
      "TeamTimeRowDto": {
        "type": "object",
        "properties": {
          "userCode": {
            "type": "string",
            "description": "The team member's user code",
            "nullable": true
          },
          "userName": {
            "type": "string",
            "description": "The team member's display name",
            "nullable": true
          },
          "isFormerMember": {
            "type": "boolean",
            "description": "True when the member has left the practice and only appears because they logged\ntime inside the window"
          },
          "loggedMinutes": {
            "type": "integer",
            "description": "Minutes logged in the window",
            "format": "int32"
          },
          "billableMinutes": {
            "type": "integer",
            "description": "Of those, the minutes marked billable",
            "format": "int32"
          },
          "nonBillableMinutes": {
            "type": "integer",
            "description": "Of those, the minutes not marked billable",
            "format": "int32"
          },
          "entryCount": {
            "type": "integer",
            "description": "Number of time entries behind the total",
            "format": "int32"
          },
          "daysLogged": {
            "type": "integer",
            "description": "Number of distinct dates anything was logged on",
            "format": "int32"
          },
          "workingPatternName": {
            "type": "string",
            "description": "The name of the working pattern this member is measured against — their own when they\nare on one, otherwise the practice default. Null when the practice has no patterns",
            "nullable": true
          },
          "expectedWeeklyMinutes": {
            "type": "integer",
            "description": "The total minutes that pattern expects in a full week. Null when there is no pattern",
            "format": "int32",
            "nullable": true
          },
          "hasOwnPattern": {
            "type": "boolean",
            "description": "True when the member is on a working pattern of their own rather than the practice\ndefault — worth surfacing so a part-timer's smaller expectation reads as deliberate"
          },
          "expectedMinutes": {
            "type": "integer",
            "description": "Minutes the member was expected to log over the window — their pattern's days summed\nacross it, bank holidays excluded, capped at today. Null when they have no pattern",
            "format": "int32",
            "nullable": true
          },
          "timeOffMinutes": {
            "type": "integer",
            "description": "The minutes the member's time off took out of their expected hours over the same days.\nZero when they had none",
            "format": "int32"
          },
          "varianceMinutes": {
            "type": "integer",
            "description": "Logged minus expected — positive means over. Null when there is no expectation",
            "format": "int32",
            "nullable": true
          },
          "variancePct": {
            "type": "number",
            "description": "Variance as a percentage of expected. Null when there is no expectation, or when the\nexpectation works out at zero minutes (a window with no working days in it yet)",
            "format": "double",
            "nullable": true
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TeamTimeDayDto"
            },
            "description": "Minutes logged per day across the window, oldest first. Only populated for windows\nshort enough to show as day cells — empty on longer ones",
            "nullable": true
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TeamTimeCategoryDto"
            },
            "description": "This member's minutes split by task category, one entry per category in the report's\nSodiumHQ.DTOs.Reports.TeamTimeReportDto.Categories column set and in the same order, including\nthe categories they logged nothing in. Always sums to SodiumHQ.DTOs.Reports.TeamTimeRowDto.LoggedMinutes",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One team member's row on the Team Time report"
      },
      "TeamTimeRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TeamTimeRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TeamTimeSummaryDto": {
        "type": "object",
        "properties": {
          "totalLoggedMinutes": {
            "type": "integer",
            "description": "Total minutes logged by everyone in the window",
            "format": "int32"
          },
          "billableMinutes": {
            "type": "integer",
            "description": "Minutes marked billable in the window",
            "format": "int32"
          },
          "totalExpectedMinutes": {
            "type": "integer",
            "description": "Total minutes everyone was expected to log, summed over the members who have an\nexpectation. Null when the practice has set no standard week and nobody has an override",
            "format": "int32",
            "nullable": true
          },
          "varianceMinutes": {
            "type": "integer",
            "description": "Logged minus expected across the members who have an expectation — positive means the\nteam logged more than expected. Null when there is no expectation to compare against",
            "format": "int32",
            "nullable": true
          },
          "variancePct": {
            "type": "number",
            "description": "Variance as a percentage of expected. Null when there is no expectation to compare against",
            "format": "double",
            "nullable": true
          },
          "userCount": {
            "type": "integer",
            "description": "Number of team members in the report",
            "format": "int32"
          },
          "usersWithNoTimeCount": {
            "type": "integer",
            "description": "Number of team members who logged nothing at all in the window",
            "format": "int32"
          },
          "startDate": {
            "type": "string",
            "description": "The window the report covers (inclusive)",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "The window end the report covers (inclusive)",
            "format": "date"
          },
          "isExpectedToDate": {
            "type": "boolean",
            "description": "True when the window runs past today, so expected minutes are pro-rated to the working\ndays elapsed so far rather than the whole window. Mid-week the comparison is\nlike-for-like instead of everyone showing as under"
          },
          "expectedUpToDate": {
            "type": "string",
            "description": "The last date expectations are counted up to — the window end, or today when the\nwindow runs past it",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "Headline aggregates for the Team Time report"
      },
      "TeamTimeTeamTotalDto": {
        "type": "object",
        "properties": {
          "teamCode": {
            "type": "string",
            "nullable": true
          },
          "teamName": {
            "type": "string",
            "nullable": true
          },
          "memberCount": {
            "type": "integer",
            "description": "The team's members in the report's cohort",
            "format": "int32"
          },
          "loggedMinutes": {
            "type": "integer",
            "format": "int32"
          },
          "expectedMinutes": {
            "type": "integer",
            "description": "The members' expected minutes added up, after their time off. Null when none of them has\nan expectation (no working pattern, or the report is narrowed to one category)",
            "format": "int32",
            "nullable": true
          },
          "timeOffMinutes": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One team's totals over its members in the report's cohort"
      },
      "TeamWorkloadReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/TeamWorkloadSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/TeamWorkloadRowDtoPagedResult"
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC).",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Team Workload & Productivity report: who's carrying how much open work right now,\nand who completed what over the window."
      },
      "TeamWorkloadRowDto": {
        "type": "object",
        "properties": {
          "groupKind": {
            "$ref": "#/components/schemas/ReportGroupKind"
          },
          "groupCode": {
            "type": "string",
            "description": "Entity code (TenantUser or Team code). Null for the unassigned bucket.",
            "nullable": true
          },
          "groupName": {
            "type": "string",
            "description": "Display name for the group.",
            "nullable": true
          },
          "openCount": {
            "type": "integer",
            "description": "Open tasks right now for this assignee.",
            "format": "int32"
          },
          "overdueCount": {
            "type": "integer",
            "description": "Open tasks past their due date right now.",
            "format": "int32"
          },
          "blockedCount": {
            "type": "integer",
            "description": "Open tasks currently blocked.",
            "format": "int32"
          },
          "completedCount": {
            "type": "integer",
            "description": "Tasks completed in the window. For the User grouping this is who actually completed\nthe task; for the Team grouping, the task's assigned team.",
            "format": "int32"
          },
          "avgTurnaroundDays": {
            "type": "number",
            "description": "Average calendar days from planned start to completion. Null when nothing completed.",
            "format": "double",
            "nullable": true
          },
          "onTimePct": {
            "type": "number",
            "description": "Percentage of this group's completions delivered on or before the due date.\nNull when nothing completed.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One row of the Team Workload breakdown table - one assignee's open workload and throughput."
      },
      "TeamWorkloadRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TeamWorkloadRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TeamWorkloadSummaryDto": {
        "type": "object",
        "properties": {
          "openCount": {
            "type": "integer",
            "description": "Open tasks right now (Not Started, In Progress, or Blocked).",
            "format": "int32"
          },
          "overdueCount": {
            "type": "integer",
            "description": "Open tasks past their due date right now.",
            "format": "int32"
          },
          "blockedCount": {
            "type": "integer",
            "description": "Open tasks currently blocked.",
            "format": "int32"
          },
          "unassignedCount": {
            "type": "integer",
            "description": "Open tasks with no assigned user or team.",
            "format": "int32"
          },
          "completedCount": {
            "type": "integer",
            "description": "Tasks completed in the window.",
            "format": "int32"
          },
          "avgTurnaroundDays": {
            "type": "number",
            "description": "Average calendar days from planned start to completion over the window's completions.\nNull when nothing completed.",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Headline KPIs for the Team Workload report."
      },
      "TemplateType": {
        "enum": [
          "EngagementLetter",
          "Proposal",
          "AdHoc",
          "FormAnswers"
        ],
        "type": "string",
        "example": "EngagementLetter"
      },
      "TemplateValidationResultDto": {
        "type": "object",
        "properties": {
          "isValid": {
            "type": "boolean",
            "description": "True when the content parses cleanly; false when the parser rejected it."
          },
          "error": {
            "type": "string",
            "description": "The parser's error message when invalid (e.g. \"Invalid 'if' tag at (10:9)\"); null when valid.",
            "nullable": true
          },
          "line": {
            "type": "integer",
            "description": "1-based line of the first error when the parser reports one; null otherwise.",
            "format": "int32",
            "nullable": true
          },
          "column": {
            "type": "integer",
            "description": "1-based column of the first error when the parser reports one; null otherwise.",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Result of validating a Liquid template fragment. Reports whether the content parses\nunder the same engine used at render time, plus the location of the first error."
      },
      "TemplateVariables": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "Document-level title (e.g., \"Engagement Letter\", \"Annual Proposal\").\nUsed in cover pages and headers.",
            "nullable": true
          },
          "subtitle": {
            "type": "string",
            "description": "Document-level subtitle providing additional context.\nTypically appears below the main title.",
            "nullable": true
          },
          "secondarySubtitle": {
            "type": "string",
            "description": "Optional secondary subtitle for additional document identification.",
            "nullable": true
          },
          "postalAddress": {
            "type": "string",
            "nullable": true
          },
          "addressee": {
            "type": "string",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "Pre-formatted ordinal date string (e.g. \"27th June 2025).\nThis is a baked string and cannot be re-formatted. Use {{ Today | formatDate: \"...\" }}\nwhen you need a custom format.",
            "nullable": true
          },
          "logo": {
            "type": "string",
            "description": "URL or base64-encoded image data for the practice logo.\nCan be used with filters like: {{ Logo | width: 200 }}",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientDto"
          },
          "business": {
            "$ref": "#/components/schemas/BusinessDetailsDto"
          },
          "vat": {
            "$ref": "#/components/schemas/VatPeriodTokens"
          },
          "task": {
            "$ref": "#/components/schemas/TaskTokens"
          },
          "periodAnchor": {
            "type": "string",
            "description": "Reference date the filing-period tokens (Vat, TaxQuarter, TaxMonth) are resolved against -\nthe source task's start date for task-driven content, else null (today). Internal plumbing,\nread by the rendering service; not a user-facing token.",
            "format": "date",
            "nullable": true
          },
          "clientRegisteredAddress": {
            "type": "string",
            "description": "Single resolved address for letter headers and templates, automatically chosen by client type:\nbusinesses use Companies House registered office (falling back to postal address);\nindividuals and sole traders use the primary contact's address.\nUsage in templates: {{ Client.RegisteredAddress }} (rewritten to ClientRegisteredAddress before parse).",
            "nullable": true
          },
          "clientNiNumber": {
            "type": "string",
            "description": "National Insurance Number sourced from the primary contact, populated only for\nIndividual and Sole Trader clients (other types have no meaningful client-level NI).\nUsage in templates: {{ Client.NiNumber }} (rewritten to ClientNiNumber before parse).",
            "nullable": true
          },
          "clientCgtReference": {
            "type": "string",
            "description": "Capital Gains Tax on UK property account number sourced from the primary contact, populated\nonly for Individual and Sole Trader clients.\nUsage in templates: {{ Client.CgtReference }} (rewritten to ClientCgtReference before parse).",
            "nullable": true
          },
          "clientHomeAddress": {
            "type": "string",
            "description": "Residential (home) address for self-assessment, sourced from the primary contact for\nIndividual and Sole Trader clients; null for company types. Distinct from\nClientRegisteredAddress, which is the business/correspondence address.\nUsage in templates: {{ Client.HomeAddress }} (rewritten to ClientHomeAddress before parse).",
            "nullable": true
          },
          "clientDateOfBirth": {
            "type": "string",
            "description": "Date of birth sourced from the primary contact, populated only for Individual and Sole Trader\nclients; null for company types. DateOnly so it renders short by default and supports formatDate.\nUsage in templates: {{ Client.DateOfBirth }} (rewritten to ClientDateOfBirth before parse).",
            "format": "date",
            "nullable": true
          },
          "clientUtr": {
            "type": "string",
            "description": "Unique Taxpayer Reference resolved by client type: the primary contact's personal UTR for\nIndividual and Sole Trader clients, the business UTR for all other types.\nUsage in templates: {{ Client.Utr }} (rewritten to ClientUtr before parse).",
            "nullable": true
          },
          "clientMaritalStatus": {
            "type": "string",
            "description": "Marital status (friendly display name) sourced from the primary contact, populated only for\nIndividual and Sole Trader clients; null for company types.\nUsage in templates: {{ Client.MaritalStatus }} (rewritten to ClientMaritalStatus before parse).",
            "nullable": true
          },
          "businessVatRegistrationDate": {
            "type": "string",
            "description": "The client's VAT registration date. DateOnly (the stored value is a DateTime) so it renders short\nby default and supports formatDate, exactly like the other date tokens; the raw DateTime renders\nas a UTC timestamp and shifts a day over BST.\nUsage in templates: {{ Business.Vat.RegistrationDate }} (rewritten to BusinessVatRegistrationDate before parse).",
            "format": "date",
            "nullable": true
          },
          "businessVatScheme": {
            "type": "string",
            "description": "The client's VAT scheme as its friendly display name (e.g. \"Flat Rate Scheme\"), not the raw\nenum member name. Null when no scheme is recorded.\nUsage in templates: {{ Business.Vat.Scheme }} (rewritten to BusinessVatScheme before parse).",
            "nullable": true
          },
          "businessVatReportingPeriod": {
            "type": "string",
            "description": "The client's VAT reporting period as its friendly display name (e.g. \"Quarterly (ending Jan, Apr,\nJul, Oct)\"), not the raw enum member name. Null when no reporting period is recorded.\nUsage in templates: {{ Business.Vat.ReportingPeriod }} (rewritten to BusinessVatReportingPeriod before parse).",
            "nullable": true
          },
          "primaryContact": {
            "$ref": "#/components/schemas/ContactDto"
          },
          "billingContact": {
            "$ref": "#/components/schemas/ContactDto"
          },
          "payrollContact": {
            "$ref": "#/components/schemas/ContactDto"
          },
          "accountsContact": {
            "$ref": "#/components/schemas/ContactDto"
          },
          "partner": {
            "$ref": "#/components/schemas/TenantUserDto"
          },
          "manager": {
            "$ref": "#/components/schemas/TenantUserDto"
          },
          "practice": {
            "$ref": "#/components/schemas/PracticeDetailsDto"
          },
          "engagement": {
            "$ref": "#/components/schemas/EngagementDto"
          },
          "proposal": {
            "$ref": "#/components/schemas/EngagementDto"
          },
          "hasProposal": {
            "type": "boolean",
            "description": "Indicates whether the engagement includes a proposal.\nReturns true if Engagement.Type is ProposalAndEngagementLetter.\nUsage in templates: {% if HasProposal %}...{% endif %}",
            "readOnly": true
          },
          "keyDates": {
            "type": "object",
            "additionalProperties": { },
            "description": "Client key dates keyed by the ClientDateType enum name (e.g., YearEnd, AccountsNextDue).\nValues are typed DateOnly objects so Fluid renders them as dd-MM-yyyy by default\nand the formatDate filter works natively (e.g., {{ KeyDates.YearEnd | formatDate: \"MMMM yyyy\" }}).\nNull/missing dates are stored as empty string.",
            "nullable": true
          },
          "customFields": {
            "type": "object",
            "additionalProperties": { },
            "description": "Client custom field values keyed by the custom field definition code.\nOnly includes supported types: Text, Number, Date, Boolean.\nValues are stored as typed objects (string, decimal, DateTime, \"Yes\"/\"No\")\nso Fluid filters like formatDate and formatCurrency work natively.\nUsage in templates: {{ CustomFields.cf-vat-number }}, {{ CustomFields.cf-start-date | formatDate: \"MMMM yyyy\" }}",
            "nullable": true
          },
          "numberFormats": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/NumberFormat"
            },
            "description": "How number custom fields and number custom tokens print, keyed \"CustomFields.{code}\" and \"Custom.{identifier}\".\nOnly those with a format set are listed. Not a token: the renderer applies each format to its value, which\nstays a number underneath, so an explicit filter ({{ CustomFields.fee | formatCurrency }}) still wins.",
            "nullable": true
          },
          "htmlBlocks": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Dictionary of custom HTML blocks that can be injected into templates.\nThis is used for dynamic content that is provided by the client at render time,\nsuch as custom sections or other HTML fragments.\nUsage in templates: {{ HtmlBlocks.CustomSection }}\nNote: HtmlBlocks.ProposalCosts is deprecated — the proposal costs table is now\nrendered by the 'proposal_costs' content block from the server-computed Costs data.",
            "nullable": true
          },
          "costs": {
            "$ref": "#/components/schemas/ProposalCosts"
          },
          "schedules": {
            "$ref": "#/components/schemas/ContentBlockCollection"
          },
          "url": {
            "type": "string",
            "description": "Generic URL for use in templates (e.g., authorization links, callback URLs, external resources).\nUsage in templates: {{ Url }}",
            "nullable": true
          },
          "outstanding": {
            "type": "string",
            "description": "What a chase text says the recipient has outstanding, e.g. \"3 things\" (docs/features/WorkflowTextMessages/PLAN.md\nD17); null everywhere else. Usage in templates: {{ Outstanding }}",
            "nullable": true
          },
          "buttonText": {
            "type": "string",
            "description": "Button text for use in templates (e.g., confirmation button text).\nUsage in templates: {{ ButtonText }}",
            "nullable": true
          },
          "contact": {
            "$ref": "#/components/schemas/ContactDto"
          },
          "summary": {
            "type": "string",
            "description": "Summary or description text (e.g., document summary).\nUsage in templates: {{ Summary }}",
            "nullable": true
          },
          "items": {
            "$ref": "#/components/schemas/RequestItemTokens"
          },
          "line": {
            "type": "string",
            "description": "The line of a client custom field that an information request item repeats over, while that item is rendered;\nnull everywhere else. Usage in an item: {{ Line }} statement for {{ Month.Name }}",
            "nullable": true
          },
          "form": {
            "$ref": "#/components/schemas/FormTokens"
          },
          "request": {
            "$ref": "#/components/schemas/DocumentRequestTokens"
          },
          "message": {
            "type": "string",
            "description": "Optional personal message from the sender (e.g. typed when notifying a client of a document).\nMay contain HTML. Usage in templates: {{ Message }}",
            "nullable": true
          },
          "custom": {
            "type": "object",
            "additionalProperties": { },
            "description": "User-defined custom token values keyed by token name.\nPopulated from {{ Custom.TokenName }} tokens in templates.\nUsage in templates: {{ Custom.InvoiceRef }}, {{ Custom.ProjectName }}",
            "nullable": true
          },
          "pageNumber": {
            "type": "string",
            "description": "Current page number for PDF rendering.\nSet automatically when rendering PDF footers - converts to Puppeteer span element.\nUsage in templates: {{ PageNumber }}",
            "nullable": true
          },
          "totalPages": {
            "type": "string",
            "description": "Total page count for PDF rendering.\nSet automatically when rendering PDF footers - converts to Puppeteer span element.\nUsage in templates: {{ TotalPages }}",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Root object containing all variables available for document template rendering.\nThis class serves as the data model for Liquid/Fluid template rendering,\nproviding access to client, practice, proposal, and document-level data."
      },
      "TenantCreateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the tenant organization",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating a new tenant organization"
      },
      "TenantDto": {
        "required": [
          "code",
          "name"
        ],
        "type": "object",
        "properties": {
          "code": {
            "minLength": 1,
            "type": "string",
            "description": "The URL-friendly unique identifier for the tenant (used in API paths)"
          },
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The human-readable name of the tenant"
          },
          "status": {
            "$ref": "#/components/schemas/TenantStatus"
          },
          "createdDate": {
            "type": "string",
            "description": "When the tenant was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the tenant was last updated",
            "format": "date-time",
            "nullable": true
          },
          "accountingConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "directDebitConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "amlConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "documentStorageConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "proposalConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "autoCreateClientFolders": {
            "type": "boolean",
            "description": "Whether Sodium automatically creates subfolders for each client under the document storage base folder.\nOnly applicable when an external document storage provider is connected.\nWhen false, users must manually map each client to a pre-existing folder."
          },
          "activeClientCount": {
            "type": "integer",
            "description": "Count of clients with Active status. Null when the requesting user's role has no view access to Clients.",
            "format": "int32",
            "nullable": true
          },
          "inactiveClientCount": {
            "type": "integer",
            "description": "Count of clients with Inactive status. Null when the requesting user's role has no view access to Clients.",
            "format": "int32",
            "nullable": true
          },
          "prospectClientCount": {
            "type": "integer",
            "description": "Count of clients with Prospect status. Null when the requesting user's role has no view access to Clients.",
            "format": "int32",
            "nullable": true
          },
          "lostProspectClientCount": {
            "type": "integer",
            "description": "Count of clients with LostProspect status. Null when the requesting user's role has no view access to Clients.",
            "format": "int32",
            "nullable": true
          },
          "servicesCount": {
            "type": "integer",
            "description": "Count of services in the tenant",
            "format": "int32"
          },
          "workFlowsCount": {
            "type": "integer",
            "description": "Count of workflows in the tenant",
            "format": "int32"
          },
          "usersCount": {
            "type": "integer",
            "description": "Count of users in the tenant",
            "format": "int32"
          },
          "kanbanBoardServiceCount": {
            "type": "integer",
            "description": "Count of services with kanban boards enabled",
            "format": "int32"
          },
          "kanbanBoardPipelineCount": {
            "type": "integer",
            "description": "Count of pipelines with kanban boards enabled",
            "format": "int32"
          },
          "salesPipelineEnabled": {
            "type": "boolean",
            "description": "Whether the Sales Pipeline feature is enabled for this tenant. Gates the pipeline UI."
          },
          "clientLogosEnabled": {
            "type": "boolean",
            "description": "Whether client logos are shown. Off, no client is shown with a logo or badge anywhere."
          },
          "proposalsSentThisMonth": {
            "type": "integer",
            "description": "Number of unique proposals sent this calendar month",
            "format": "int32"
          },
          "isSupportAccessEnabled": {
            "type": "boolean",
            "description": "Whether or not support access is enabled, allowing\nsupport agents to access the tenant's data for troubleshooting."
          },
          "canAccessBetaFeatures": {
            "type": "boolean",
            "description": "Whether this tenant can access beta features"
          },
          "canUseMessaging": {
            "type": "boolean",
            "description": "Whether Sodium has allowed the practice to use SMS and WhatsApp messaging (switching on, applying for a\nnumber, sending); without it they are refused with a 409 and the Settings card says to contact support"
          },
          "isDisabled": {
            "type": "boolean",
            "description": "Whether this tenant is disabled"
          },
          "disabledReason": {
            "type": "string",
            "description": "The reason the tenant was disabled, if applicable",
            "nullable": true
          },
          "isTasksDisabled": {
            "type": "boolean",
            "description": "Whether task materialization is disabled for this tenant"
          },
          "isMissingRequiredBillingInfo": {
            "type": "boolean",
            "description": "Whether this tenant is on a paid plan but hasn't completed billing/DD setup"
          },
          "isSubscriptionCancelled": {
            "type": "boolean",
            "description": "Whether this tenant has cancelled their subscription.\nCancelled tenants retain access until their current subscription ends."
          },
          "lastUserLogin": {
            "type": "string",
            "description": "The most recent login timestamp across all users in this tenant",
            "format": "date-time",
            "nullable": true
          },
          "expiredDate": {
            "type": "string",
            "description": "When the tenant's subscription expired: the EndDate of the most recently ended subscription.\nNull for tenants that have never had a subscription end. Primarily relevant for lapsed trialists and customers.",
            "format": "date-time",
            "nullable": true
          },
          "trialEndDate": {
            "type": "string",
            "description": "The EndDate of the tenant's current, in-progress free trial - a future date while the trial is running, otherwise null.\nDrives the \"days left\" countdown for active trialists. Distinct from ExpiredDate, which reflects the last subscription that already ended.",
            "format": "date-time",
            "nullable": true
          },
          "convertedDate": {
            "type": "string",
            "description": "When the tenant first moved off trial onto a real tier: the earliest StartDate among non-trial\nsubscriptions (paid or freemium). Null while still trialling, or lapsed without ever converting.",
            "format": "date-time",
            "nullable": true
          },
          "pendingSubscriptionStartDate": {
            "type": "string",
            "description": "StartDate of the earliest non-trial subscription lined up to start in the future (e.g. a package\nchosen during a trial). Null when nothing is scheduled.",
            "format": "date-time",
            "nullable": true
          },
          "pendingSubscriptionPackageName": {
            "type": "string",
            "description": "Name of the package on the pending subscription (the one PendingSubscriptionStartDate refers to)",
            "nullable": true
          },
          "currentPackageName": {
            "type": "string",
            "description": "Name of the package on the tenant's current non-trial subscription (started, not yet ended).\nNull while trialling or lapsed.",
            "nullable": true
          },
          "logoUrl": {
            "type": "string",
            "description": "The URL of the tenant's logo image",
            "nullable": true
          },
          "currentUserRoleName": {
            "type": "string",
            "description": "The requesting user's role within this tenant - the SystemRole name (\"Admin\", \"StandardUser\", \"Viewer\")\nfor system roles, or the custom role's name. Only populated by the user-facing tenant list (GET /tenants);\nnull on admin endpoints, which are not scoped to a single user's membership.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An organisation (tenant) and its configuration"
      },
      "TenantHolidayDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for the holiday",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "The date of the holiday, or its first day when it runs over several (format: yyyy-MM-dd)",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "The last day of a holiday that runs over several days (inclusive). Empty for a single day",
            "format": "date",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Name of the holiday (e.g., \"Company Anniversary\", \"Office Closure\")",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Tenant-specific custom holiday"
      },
      "TenantHolidayDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenantHolidayDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TenantHolidaySortField": {
        "enum": [
          "Date",
          "Name"
        ],
        "type": "string",
        "example": "Date"
      },
      "TenantInfo": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The tenant's unique code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The tenant's name",
            "nullable": true
          },
          "joinedDate": {
            "type": "string",
            "description": "When the user was added to this tenant",
            "format": "date-time"
          },
          "accountingConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "directDebitConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "amlConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "documentStorageConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "proposalConnection": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "autoCreateClientFolders": {
            "type": "boolean",
            "description": "Whether Sodium automatically creates subfolders for each client under the document storage base folder.\nOnly applicable when an external document storage provider is connected."
          },
          "activeClientCount": {
            "type": "integer",
            "description": "Count of clients with Active status. Null when the user's role has no view access to Clients.",
            "format": "int32",
            "nullable": true
          },
          "inactiveClientCount": {
            "type": "integer",
            "description": "Count of clients with Inactive status. Null when the user's role has no view access to Clients.",
            "format": "int32",
            "nullable": true
          },
          "prospectClientCount": {
            "type": "integer",
            "description": "Count of clients with Prospect status. Null when the user's role has no view access to Clients.",
            "format": "int32",
            "nullable": true
          },
          "lostProspectClientCount": {
            "type": "integer",
            "description": "Count of clients with LostProspect status. Null when the user's role has no view access to Clients.",
            "format": "int32",
            "nullable": true
          },
          "servicesCount": {
            "type": "integer",
            "description": "Count of services in the tenant",
            "format": "int32"
          },
          "workFlowsCount": {
            "type": "integer",
            "description": "Count of workflows in the tenant",
            "format": "int32"
          },
          "usersCount": {
            "type": "integer",
            "description": "Count of users in the tenant",
            "format": "int32"
          },
          "kanbanBoardServiceCount": {
            "type": "integer",
            "description": "Count of services with kanban boards enabled",
            "format": "int32"
          },
          "kanbanBoardPipelineCount": {
            "type": "integer",
            "description": "Count of pipelines with kanban boards enabled",
            "format": "int32"
          },
          "salesPipelineEnabled": {
            "type": "boolean",
            "description": "Whether the Sales Pipeline feature is enabled for this tenant. Gates the pipeline UI."
          },
          "connectedProducts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SodiumProduct"
            },
            "description": "The other Sodium products the practice is connected to (it has their Account Hub service link). Filled on the\nsigned-in user's own record (GET /tenants/{code}/me); empty elsewhere, and when Account Hub cannot be reached",
            "nullable": true
          },
          "clientLogosEnabled": {
            "type": "boolean",
            "description": "Whether client logos are shown. Off, no client is shown with a logo or badge anywhere."
          },
          "hasRestrictedClients": {
            "type": "boolean",
            "description": "Whether any client in the practice has restricted access. The web app uses it to skip its client visibility\nwarnings' client fetch in practices with no restricted client and no restricted user."
          },
          "canAccessBetaFeatures": {
            "type": "boolean",
            "description": "Whether the tenant can access beta features"
          },
          "canUseMessaging": {
            "type": "boolean",
            "description": "Whether Sodium has allowed the practice to use SMS and WhatsApp messaging (switching on, applying for a\nnumber, sending); without it they are refused with a 409 and the Settings card says to contact support"
          },
          "webhooksEnabled": {
            "type": "boolean",
            "description": "Whether outbound webhooks are switched on in this environment (`Webhooks:Enabled`); off, the webhooks\nroutes answer 409 and the web app hides its Webhooks settings. Filled on the signed-in user's own record\n(GET /tenants/{code}/me); false elsewhere"
          },
          "useAlternateRendering": {
            "type": "boolean",
            "description": "Whether the web app uses its alternate rendering for this tenant"
          },
          "isDisabled": {
            "type": "boolean",
            "description": "Whether the tenant is disabled"
          },
          "isMissingRequiredBillingInfo": {
            "type": "boolean",
            "description": "Whether the tenant is on a paid plan but hasn't completed billing/DD setup"
          },
          "isSubscriptionCancelled": {
            "type": "boolean",
            "description": "Whether the tenant has cancelled their subscription"
          },
          "role": {
            "$ref": "#/components/schemas/RoleInfo"
          }
        },
        "additionalProperties": false,
        "description": "Information about a tenant that a user belongs to, including statistics and role information"
      },
      "TenantStatus": {
        "enum": [
          "LapsedTrialist",
          "LapsedCustomer",
          "ActiveTrialist",
          "PendingConversion",
          "PayingCustomer",
          "Freemium",
          "DemoAccount"
        ],
        "type": "string",
        "example": "LapsedTrialist"
      },
      "TenantUpdateRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The human-readable name of the tenant"
          },
          "accountingConnectionCode": {
            "type": "string",
            "description": "The code of the accounting connection to use for this tenant\nTo clear it, set to an empty string rather than null.",
            "nullable": true
          },
          "directDebitConnectionCode": {
            "type": "string",
            "description": "The code of the direct debit connection to use for this tenant\nTo clear it, set to an empty string rather than null.",
            "nullable": true
          },
          "amlConnectionCode": {
            "type": "string",
            "description": "The code of the AML connection to use for this tenant\nTo clear it, set to an empty string rather than null.",
            "nullable": true
          },
          "documentStorageConnectionCode": {
            "type": "string",
            "description": "The code of the document storage connection to use for this tenant\nTo clear it, set to an empty string rather than null.",
            "nullable": true
          },
          "proposalConnectionCode": {
            "type": "string",
            "description": "The code of the external proposal platform connection to use for this tenant.\nTo clear it, set to an empty string rather than null.",
            "nullable": true
          },
          "autoCreateClientFolders": {
            "type": "boolean",
            "description": "Whether Sodium automatically creates subfolders for each client under the document storage base folder.\nOnly applicable when an external document storage provider is connected.\nWhen false, users must manually map each client to a pre-existing folder.\nIf null, the existing value will not be changed.",
            "nullable": true
          },
          "isSupportAccessEnabled": {
            "type": "boolean",
            "description": "Whether support access is enabled for this tenant.\nIf null, the existing value will not be changed.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a tenant"
      },
      "TenantUserDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this user within the tenant",
            "nullable": true
          },
          "displayName": {
            "type": "string",
            "description": "The display name for the user (returns full name if available, otherwise email)",
            "nullable": true,
            "readOnly": true
          },
          "email": {
            "type": "string",
            "description": "The user's email address",
            "format": "email",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "description": "The user's first name",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "description": "The user's last name",
            "nullable": true
          },
          "isSuperAdmin": {
            "type": "boolean",
            "description": "Whether the user is a super admin"
          },
          "isSupportAccess": {
            "type": "boolean",
            "description": "Whether this user is accessing the tenant via support access (not a regular team member)"
          },
          "avatar": {
            "type": "string",
            "description": "The user's avatar URL",
            "nullable": true
          },
          "userCode": {
            "type": "string",
            "description": "The global user code, for linking to admin user records",
            "nullable": true
          },
          "lastLogin": {
            "type": "string",
            "description": "The user's last login timestamp",
            "format": "date-time",
            "nullable": true
          },
          "authProvider": {
            "$ref": "#/components/schemas/AuthProviderType"
          },
          "status": {
            "$ref": "#/components/schemas/TenantUserStatus"
          },
          "invitationExpiresOn": {
            "type": "string",
            "description": "When the invitation expires (null if not invited or if joined directly)",
            "format": "date-time",
            "nullable": true
          },
          "invitationAcceptedAt": {
            "type": "string",
            "description": "When the invitation was accepted (null if still pending)",
            "format": "date-time",
            "nullable": true
          },
          "hourlyRate": {
            "type": "number",
            "description": "The current charge-out rate per hour, from the user's open rate entry.\nFalls back to the practice default rate when null. Read-only — rates are\nmanaged via the user's rates endpoints.",
            "format": "double",
            "nullable": true
          },
          "costRate": {
            "type": "number",
            "description": "The current internal cost rate per hour, from the user's open rate entry.\nNull when none is set, or when the caller lacks the Cost Rates permission.",
            "format": "double",
            "nullable": true
          },
          "workingPattern": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "onLeaveUntil": {
            "type": "string",
            "description": "The last day of the time off the user is on today, so pickers can flag them as on leave.\nNull when they're working today. Never says what kind of time off it is",
            "format": "date",
            "nullable": true
          },
          "tenant": {
            "$ref": "#/components/schemas/TenantInfo"
          }
        },
        "additionalProperties": false,
        "description": "DTO for a user within a tenant, including their role and basic information."
      },
      "TenantUserDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenantUserDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TenantUserRateDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this rate entry",
            "nullable": true
          },
          "hourlyRate": {
            "type": "number",
            "description": "Charge-out rate per hour. Null falls back to the practice default rate.",
            "format": "double",
            "nullable": true
          },
          "costRate": {
            "type": "number",
            "description": "Internal cost rate per hour. Null when none is set for the period, or when the\ncaller lacks the Cost Rates permission.",
            "format": "double",
            "nullable": true
          },
          "effectiveFrom": {
            "type": "string",
            "description": "The first day the rates apply. Null means \"since forever\".",
            "format": "date",
            "nullable": true
          },
          "effectiveTo": {
            "type": "string",
            "description": "The last day the rates apply (inclusive). Null marks the current rate.",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A date-effective rate entry for a team member. A user has at most one open entry\n(null effectiveTo — the current rate) and entries never overlap."
      },
      "TenantUserSortField": {
        "enum": [
          "LastName",
          "FirstName",
          "Email",
          "Status",
          "Role",
          "LastLogin"
        ],
        "type": "string",
        "example": "LastName"
      },
      "TenantUserStatus": {
        "enum": [
          "Created",
          "Invited",
          "Active",
          "Disabled",
          "Declined",
          "Deleted"
        ],
        "type": "string",
        "example": "Created"
      },
      "TestEmailBroadcastRequest": {
        "required": [
          "clientCode"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the sample client to render the email for.",
            "example": "acme-ltd"
          }
        },
        "additionalProperties": false,
        "description": "Request to send a test of a broadcast email to the current user.\nThe email is rendered with the sample client's data but sent only to the caller's own address."
      },
      "TestEmailRequest": {
        "type": "object",
        "properties": {
          "recipientEmail": {
            "type": "string",
            "description": "Email address to send the test email to",
            "nullable": true
          },
          "recipientName": {
            "type": "string",
            "description": "Optional name of the recipient",
            "nullable": true
          },
          "subject": {
            "type": "string",
            "description": "Optional custom subject line. Defaults to \"Test Email - Configuration Verification\" if not provided.",
            "nullable": true
          },
          "htmlBody": {
            "type": "string",
            "description": "Optional custom HTML body. Defaults to a standard verification message if not provided.",
            "nullable": true
          },
          "plainTextBody": {
            "type": "string",
            "description": "Optional custom plain text body. Defaults to a standard verification message if not provided.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to send a test email for verifying configuration"
      },
      "TestEmailResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Indicates if the test email was sent successfully"
          },
          "message": {
            "type": "string",
            "description": "Human-readable message describing the result",
            "nullable": true
          },
          "error": {
            "type": "string",
            "description": "Error details if the test email failed (null on success)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response from sending a test email"
      },
      "TextBroadcastAudienceRequest": {
        "type": "object",
        "properties": {
          "savedViewCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The code of a saved client view whose filter selects which clients to include. The view's criteria are resolved\nwhen recipients are resolved, so later changes to the view are picked up until the text is sent. Mutually\nexclusive with Filter.",
            "nullable": true,
            "example": "active-limited-companies"
          },
          "filter": {
            "$ref": "#/components/schemas/EmailBroadcastFilterDto"
          },
          "excludedClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Client codes to exclude from the filter results",
            "nullable": true
          },
          "additionalClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hand-picked client codes to add on top of the filter results",
            "nullable": true
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "The client contact types texted at each client, on their mobiles. A draft needs at least one; a summary with none\nworks out only the client and preference counts.",
            "nullable": true
          },
          "sendOncePerNumber": {
            "type": "boolean",
            "description": "When true (the default), a number held by contacts at several clients is texted once, with the first client's\ntokens; the other clients are skipped",
            "example": true
          }
        },
        "additionalProperties": false,
        "description": "The client selection of a bulk text and who at each client is texted: a saved view or an inline filter (not both),\nplus additions, less exclusions. Summarised on its own before a draft exists, and the audience part of the create\nand update requests."
      },
      "TextBroadcastAudienceSummaryDto": {
        "type": "object",
        "properties": {
          "clientCount": {
            "type": "integer",
            "description": "Clients the selection resolves to (filter matches plus hand-picked additions, minus exclusions)",
            "format": "int32",
            "example": 142
          },
          "preferenceOffCount": {
            "type": "integer",
            "description": "Of those, clients whose contact preferences do not allow text messages; they are never texted",
            "format": "int32",
            "example": 6
          },
          "recipientCount": {
            "type": "integer",
            "description": "Numbers that would be texted. Null when the request named no contact types.",
            "format": "int32",
            "nullable": true,
            "example": 128
          },
          "noMobileCount": {
            "type": "integer",
            "description": "Clients that may be texted but have no chosen contact with a usable mobile number. Null when the request named no\ncontact types.",
            "format": "int32",
            "nullable": true,
            "example": 9
          },
          "doNotTextCount": {
            "type": "integer",
            "description": "Numbers on the practice's do-not-text list. Null when the request named no contact types.",
            "format": "int32",
            "nullable": true,
            "example": 1
          }
        },
        "additionalProperties": false,
        "description": "Counts for a bulk text's audience before a draft exists: how many clients the selection resolves to, how many\nnumbers would be texted, and why the rest would not be (docs/features/BulkTextMessages/PLAN.md D4 to D7)"
      },
      "TextBroadcastDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code identifying this bulk text",
            "nullable": true,
            "example": "20261113a"
          },
          "name": {
            "type": "string",
            "description": "What the bulk text is called",
            "nullable": true,
            "example": "January self assessment reminder"
          },
          "status": {
            "$ref": "#/components/schemas/BroadcastStatus"
          },
          "routing": {
            "$ref": "#/components/schemas/MessagingRequestTextRouting"
          },
          "templateCode": {
            "type": "string",
            "description": "The practice text template whose body is the SMS text. Mutually exclusive with Body.",
            "nullable": true
          },
          "body": {
            "type": "string",
            "description": "The SMS text with Liquid tokens. Mutually exclusive with TemplateCode.",
            "nullable": true
          },
          "whatsAppTemplateId": {
            "type": "string",
            "description": "The WhatsApp template sent where the routing chooses WhatsApp; null with SmsOnly routing",
            "format": "uuid",
            "nullable": true
          },
          "contentVariables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "What fills each of the WhatsApp template's placeholders; null with SmsOnly routing",
            "nullable": true
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "The client contact types texted at each client",
            "nullable": true
          },
          "savedView": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "filter": {
            "$ref": "#/components/schemas/EmailBroadcastFilterDto"
          },
          "excludedClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Client codes excluded from the filter results",
            "nullable": true
          },
          "additionalClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hand-picked client codes added on top of the filter results",
            "nullable": true
          },
          "sendOncePerNumber": {
            "type": "boolean",
            "description": "Whether a number shared by several clients is texted once",
            "example": true
          },
          "pausedReason": {
            "type": "string",
            "description": "Why a paused send stopped; null unless Paused",
            "nullable": true
          },
          "totalRecipients": {
            "type": "integer",
            "description": "Numbers to text, set when sent",
            "format": "int32",
            "example": 0
          },
          "processedRecipients": {
            "type": "integer",
            "description": "Numbers processed so far (sent + failed)",
            "format": "int32",
            "example": 0
          },
          "failedRecipients": {
            "type": "integer",
            "description": "Numbers whose send failed so far",
            "format": "int32",
            "example": 0
          },
          "deliveredRecipients": {
            "type": "integer",
            "description": "Numbers whose message was delivered (or read), from the delivery events; 0 for a draft",
            "format": "int32",
            "example": 0
          },
          "deliveryFailedRecipients": {
            "type": "integer",
            "description": "Numbers whose message was accepted and later failed or went undelivered, from the delivery events (a WhatsApp\nmessage followed by its SMS counts by the SMS); 0 for a draft",
            "format": "int32",
            "example": 0
          },
          "skippedRecipients": {
            "type": "integer",
            "description": "Rows of the snapshot that were skipped (no mobile, preferences, the do-not-text list, a number texted with another\nclient…); 0 for a draft, whose skips the recipients route resolves live",
            "format": "int32",
            "example": 0
          },
          "creditsEstimated": {
            "type": "integer",
            "description": "The credits the send was estimated to cost when it was sent; null until then",
            "format": "int32",
            "nullable": true
          },
          "startedDate": {
            "type": "string",
            "description": "When sending started (UTC)",
            "format": "date-time",
            "nullable": true
          },
          "completedDate": {
            "type": "string",
            "description": "When sending finished (UTC)",
            "format": "date-time",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the bulk text was created (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "A bulk text: one text to each chosen contact's mobile at a filtered set of clients, with per-client and\nper-recipient token rendering (docs/features/BulkTextMessages/PLAN.md D2). Returned by the text broadcast routes."
      },
      "TextBroadcastDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextBroadcastDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TextBroadcastEstimateDto": {
        "type": "object",
        "properties": {
          "recipientCount": {
            "type": "integer",
            "description": "Numbers that would be texted, by either channel",
            "format": "int32",
            "example": 128
          },
          "unsendableCount": {
            "type": "integer",
            "description": "Numbers skipped because their message cannot be sent: an SMS that renders empty or too long, or a WhatsApp\nplaceholder that renders empty where the client's preferences do not allow the SMS in its place",
            "format": "int32",
            "example": 0
          },
          "segments": {
            "type": "integer",
            "description": "SMS segments across every number sent the SMS",
            "format": "int32",
            "example": 140
          },
          "whatsAppRecipientCount": {
            "type": "integer",
            "description": "Numbers that would be sent the WhatsApp message (the rest of RecipientCount get the SMS)",
            "format": "int32",
            "example": 40
          },
          "followUpSegments": {
            "type": "integer",
            "description": "SMS segments that may follow WhatsApp messages WhatsApp turns away: those to numbers not known on WhatsApp\n(\"try WhatsApp first\") whose clients allow SMS. Counted in CreditsNeeded.",
            "format": "int32",
            "example": 12
          },
          "isUpTo": {
            "type": "boolean",
            "description": "Whether CreditsNeeded is an \"up to\" figure: the bulk text may use WhatsApp",
            "example": true
          },
          "whatsAppDailyLimit": {
            "type": "integer",
            "description": "Meta's limit on the people a business can start WhatsApp conversations with in a rolling 24 hours, for a business\nportfolio Meta has not verified (shared by every number in the portfolio; a verified one has at least 2,000).\nWhen WhatsAppRecipientCount is over it, WhatsApp may refuse the rest with Twilio error 63018. Null when the bulk\ntext sends no WhatsApp message.",
            "format": "int32",
            "nullable": true,
            "example": 250
          },
          "creditsPerSmsSegment": {
            "type": "integer",
            "description": "Credits one SMS segment costs the practice",
            "format": "int32",
            "example": 1
          },
          "creditsPerWhatsAppMessage": {
            "type": "integer",
            "description": "Credits one WhatsApp message costs the practice",
            "format": "int32",
            "example": 1
          },
          "creditsNeeded": {
            "type": "integer",
            "description": "Credits the send would cost, at most: the SMS segments and follow-up segments at the SMS price, plus each\nWhatsApp message at its price",
            "format": "int32",
            "example": 192
          },
          "balance": {
            "type": "integer",
            "description": "The practice's credits now",
            "format": "int32",
            "example": 1240
          },
          "isInsideQuietHours": {
            "type": "boolean",
            "description": "Whether now is inside the practice's quiet hours. A send started by hand still goes at once.",
            "example": false
          },
          "quietHoursEnd": {
            "type": "string",
            "description": "When the quiet hours end (UTC); null outside them",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a draft bulk text would cost now (docs/features/BulkTextMessages/PLAN.md D10, D11): every recipient's message\nrendered, each SMS counted in segments with the Messaging Service's own counter, each WhatsApp message as one, at the\npractice's own prices, against its balance. With a routing that may use WhatsApp the figure is \"up to\": it includes\nthe SMS that may follow a WhatsApp message to a number not known on WhatsApp."
      },
      "TextBroadcastPreviewDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code",
            "nullable": true,
            "example": "acme-ltd"
          },
          "clientName": {
            "type": "string",
            "description": "The client's name",
            "nullable": true,
            "example": "ACME Ltd"
          },
          "recipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextBroadcastPreviewRecipientDto"
            },
            "description": "The client's recipients, in the order they are texted, then those missed",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a bulk text sends one client: each of its recipients with the channel and the text rendered for them, and\neach person missed with the reason"
      },
      "TextBroadcastPreviewRecipientDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Who is texted: the contact's name, or the contact type when the client has nobody of it",
            "nullable": true,
            "example": "Jo Smith"
          },
          "address": {
            "type": "string",
            "description": "The number, in E.164; null when there is no number to text",
            "nullable": true,
            "example": "+447700900123"
          },
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "smsReason": {
            "type": "string",
            "description": "Why SMS where WhatsApp might have been sent (\"Not known on WhatsApp.\", the client's preferences…); null on\nWhatsApp, with SMS-only routing, or when nothing is sent",
            "nullable": true,
            "example": "Not known on WhatsApp."
          },
          "text": {
            "type": "string",
            "description": "The message as it would be sent: the SMS text, or on WhatsApp the template's approved text with each placeholder\nfilled for this person (null when the template's text could not be read); null when the person is skipped before\nit is rendered",
            "nullable": true,
            "example": "Hi Jo, your tax return for ACME Ltd is due on 31 January."
          },
          "segments": {
            "type": "integer",
            "description": "SMS segments the text is sent as, the count the Messaging Service charges; 0 on WhatsApp or when nothing is sent",
            "format": "int32",
            "example": 1
          },
          "status": {
            "$ref": "#/components/schemas/TextBroadcastRecipientStatus"
          },
          "skipReason": {
            "type": "string",
            "description": "Why the person would not be texted; null when they would be",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One recipient in a bulk text's preview for a client"
      },
      "TextBroadcastRecipientDto": {
        "type": "object",
        "properties": {
          "clientCode": {
            "type": "string",
            "description": "The client's code",
            "nullable": true,
            "example": "acme-ltd"
          },
          "clientName": {
            "type": "string",
            "description": "The client's name",
            "nullable": true,
            "example": "ACME Ltd"
          },
          "contactCode": {
            "type": "string",
            "description": "The contact holding the number; null for a contact type the client has nobody for",
            "nullable": true,
            "example": "jo-smith"
          },
          "name": {
            "type": "string",
            "description": "Who is texted: the contact's name, or the contact type when the client has nobody of it",
            "nullable": true,
            "example": "Jo Smith"
          },
          "address": {
            "type": "string",
            "description": "The number, in E.164; null when there is no number to text",
            "nullable": true,
            "example": "+447700900123"
          },
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "smsReason": {
            "type": "string",
            "description": "Why SMS where WhatsApp might have been sent; null on WhatsApp or with SMS-only routing",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TextBroadcastRecipientStatus"
          },
          "skipOrFailReason": {
            "type": "string",
            "description": "Why this number was skipped or its send failed; null when Pending or Sent",
            "nullable": true,
            "example": "Jo Smith has no mobile number."
          },
          "deliveryStatus": {
            "$ref": "#/components/schemas/MessageStatus"
          },
          "deliveryError": {
            "type": "string",
            "description": "The service's error for an undelivered or failed message",
            "nullable": true
          },
          "sentDate": {
            "type": "string",
            "description": "When the text was sent (UTC); null unless Sent",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One number texted, or one person missed, by a bulk text, for one client. Before the send this is a live resolution;\nafter it, the stored snapshot with its delivery status."
      },
      "TextBroadcastRecipientDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextBroadcastRecipientDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TextBroadcastRecipientSortField": {
        "enum": [
          "Default"
        ],
        "type": "string",
        "example": "Default"
      },
      "TextBroadcastRecipientStatus": {
        "enum": [
          "Pending",
          "Sent",
          "Failed",
          "Skipped"
        ],
        "type": "string",
        "example": "Pending"
      },
      "TextBroadcastRepeatedNumberDto": {
        "type": "object",
        "properties": {
          "number": {
            "type": "string",
            "description": "The number, in E.164",
            "nullable": true,
            "example": "+447700900123"
          },
          "clientNames": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The clients it is on, in selection order: the first one keeps it when texting once per number",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One number held by contacts at more than one selected client"
      },
      "TextBroadcastRepeatedNumbersDto": {
        "type": "object",
        "properties": {
          "numberCount": {
            "type": "integer",
            "description": "How many numbers are on more than one selected client",
            "format": "int32",
            "example": 3
          },
          "duplicateTextCount": {
            "type": "integer",
            "description": "How many extra texts those numbers would get: the texts sending once per number drops",
            "format": "int32",
            "example": 7
          },
          "skippedClientCount": {
            "type": "integer",
            "description": "How many clients would be texted at no number, because every number of theirs is already texted with an earlier\nclient",
            "format": "int32",
            "example": 4
          },
          "isPersonalised": {
            "type": "boolean",
            "description": "True when the text uses client-specific tokens, so each client's text differs and a number texted once only sees\nthe first client's",
            "example": true
          },
          "numbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextBroadcastRepeatedNumberDto"
            },
            "description": "The repeated numbers, most clients first (at most 20)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The numbers held by contacts at more than one of a draft bulk text's clients, and what texting each number once\ndrops (docs/features/BulkTextMessages/PLAN.md D5)"
      },
      "TextBroadcastSortField": {
        "enum": [
          "CreatedDate",
          "Status"
        ],
        "type": "string",
        "example": "CreatedDate"
      },
      "TextMessageBlockReason": {
        "enum": [
          "NotSetUp",
          "NoSender",
          "NoCredit",
          "TemplateGone",
          "NobodyToText",
          "NoAnswer",
          "NoClient",
          "NoWhatsAppSender",
          "WhatsAppTemplateUnusable",
          "DeliveryFailed"
        ],
        "type": "string",
        "example": "NotSetUp"
      },
      "TextMessageMissedDto": {
        "type": "object",
        "properties": {
          "contactType": {
            "$ref": "#/components/schemas/ClientContactType"
          },
          "name": {
            "type": "string",
            "description": "The contact's name; null when the client has no contact of the type",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "description": "Why they were not texted",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One person chosen who was never texted"
      },
      "TextMessageRecipientDto": {
        "type": "object",
        "properties": {
          "contactCode": {
            "type": "string",
            "description": "The contact's code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The contact's name",
            "nullable": true
          },
          "address": {
            "type": "string",
            "description": "The number texted, E.164",
            "nullable": true
          },
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "smsReason": {
            "type": "string",
            "description": "Why the text went by SMS where WhatsApp might have been, on a step the practice's routing chooses the channel\nfor; null when it went by WhatsApp or there is nothing to say",
            "nullable": true
          },
          "messageId": {
            "type": "string",
            "description": "The message's id in the Messaging Service, once it answered",
            "format": "uuid",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TextMessageRecipientStatus"
          },
          "error": {
            "type": "string",
            "description": "Why the text was not sent, when it Failed",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One person a text step texted or tried"
      },
      "TextMessageRecipientStatus": {
        "enum": [
          "Pending",
          "Sent",
          "Failed"
        ],
        "type": "string",
        "example": "Pending"
      },
      "ThemeFont": {
        "enum": [
          "Arial",
          "Helvetica",
          "TimesNewRoman",
          "Georgia",
          "Verdana",
          "Tahoma",
          "TrebuchetMs",
          "CourierNew",
          "LucidaConsole",
          "Calibri",
          "OpenSans",
          "Roboto",
          "Lato",
          "Montserrat",
          "Poppins",
          "Inter",
          "Nunito",
          "Raleway",
          "SourceSansPro",
          "WorkSans",
          "PlayfairDisplay",
          "Merriweather",
          "Lora",
          "PtSerif",
          "LibreBaskerville",
          "RobotoMono",
          "SourceCodePro",
          "FiraCode",
          "Custom"
        ],
        "type": "string",
        "example": "Arial"
      },
      "ThirdPartyConnectionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this connection",
            "nullable": true
          },
          "platform": {
            "type": "string",
            "description": "The platform identifier (e.g., \"Xero\", \"FreeAgent\", \"Sage\", \"QuickBooks\")",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name for the connection",
            "nullable": true
          },
          "authenticationType": {
            "$ref": "#/components/schemas/AuthenticationType"
          },
          "status": {
            "$ref": "#/components/schemas/ConnectionStatus"
          },
          "capabilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlatformCapability"
            },
            "description": "Capabilities available from this platform connection (e.g., Accounting, ClientImport)",
            "nullable": true
          },
          "redirectUrl": {
            "type": "string",
            "description": "URL to redirect the user back to after OAuth flow completes",
            "nullable": true
          },
          "authorizationUrl": {
            "type": "string",
            "description": "OAuth authorization URL for initiating the connection flow",
            "nullable": true
          },
          "organization": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "availableOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "List of available organizations from the connected platform (populated during OAuth callback)",
            "nullable": true
          },
          "supportsMultipleStorageLocations": {
            "type": "boolean",
            "description": "Whether this connection supports assigning different storage locations to individual\nclients (e.g. per-client SharePoint sites). When true, the storage-locations endpoint\nis available and the frontend should show a location picker on client folder assignment."
          },
          "supportsFileMove": {
            "type": "boolean",
            "description": "Whether files can be moved between folders on this platform. When true, the frontend\nenables drag-and-drop of files onto folders in the client documents list."
          },
          "useExtendedScopes": {
            "type": "boolean",
            "description": "Whether this connection was authorised with the platform's extended scopes as well as its base scopes.\nThe level can be chosen again when reconnecting; when it is not sent, the reconnect keeps this value."
          },
          "authorisingUserEmail": {
            "type": "string",
            "description": "The email of the account that authorised this connection, where the platform reports one.",
            "nullable": true
          },
          "documentCount": {
            "type": "integer",
            "description": "How many documents are stored through this connection. Returned for document storage\nconnections only; null otherwise.",
            "format": "int32",
            "nullable": true
          },
          "clientFolderCount": {
            "type": "integer",
            "description": "How many client folder mappings this connection holds. Returned for document storage\nconnections only; null otherwise.",
            "format": "int32",
            "nullable": true
          },
          "linkedClientCount": {
            "type": "integer",
            "description": "How many clients are linked to their own organisation through this connection. Returned for\naccounting and bookkeeping health connections only; null otherwise.",
            "format": "int32",
            "nullable": true
          },
          "clientLinkedOrganizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The organisations this grant reaches that are linked to a client's books: code is the organisation id,\nname the client (or clients). Returned while an organisation is being chosen; null otherwise.",
            "nullable": true
          },
          "warning": {
            "type": "string",
            "description": "Something worth knowing about a working connection, such as a meeting notes connection made with one person's\nown key. Only on a single connection read.",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the connection was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the connection was last updated",
            "format": "date-time",
            "nullable": true
          },
          "lastUsedDate": {
            "type": "string",
            "description": "When this connection was last used to call the platform, or null if it has not been used since\nusage tracking was introduced (it cannot be backfilled). Excludes automatic token refreshes, so a\nlong-idle value here means nobody is using the connection and it can be disconnected.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents an OAuth or API key connection to a third-party platform such as Xero, FreeAgent, Sage, or QuickBooks.\nUsed for integrating accounting platforms, client imports, and other external services."
      },
      "ThirdPartyConnectionDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ThirdPartyConnectionDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ThirdPartyConnectionSortField": {
        "enum": [
          "Name",
          "Platform",
          "LastUsedDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "ThirdPartyPlatformMetadata": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "nullable": true
          },
          "displayName": {
            "type": "string",
            "nullable": true
          },
          "authenticationType": {
            "type": "string",
            "nullable": true
          },
          "grantScope": {
            "$ref": "#/components/schemas/GrantScope"
          },
          "capabilities": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "iconUrl": {
            "type": "string",
            "nullable": true
          },
          "logoUrl": {
            "type": "string",
            "nullable": true
          },
          "supportsProfitAndLoss": {
            "type": "boolean"
          },
          "supportsTrialBalance": {
            "type": "boolean"
          },
          "supportsBalanceSheet": {
            "type": "boolean"
          },
          "supportsBooksTransactionDetail": {
            "type": "boolean"
          },
          "bankTransactions": {
            "$ref": "#/components/schemas/BankTransactionsSupport"
          },
          "bankTransactionsUnreconciledLabel": {
            "type": "string",
            "nullable": true
          },
          "supportsPracticeBooks": {
            "type": "boolean"
          },
          "supportsMtdFigures": {
            "type": "boolean"
          },
          "supportsCashBasisReporting": {
            "type": "boolean"
          },
          "supportsDraftInvoices": {
            "type": "boolean"
          },
          "supportsSendInvoice": {
            "type": "boolean"
          },
          "supportsRiskAssessments": {
            "type": "boolean"
          },
          "supportsOnboarding": {
            "type": "boolean"
          },
          "supportsOnboardingEmail": {
            "type": "boolean"
          },
          "supportsOnboardingCancel": {
            "type": "boolean"
          },
          "supportsContactStatus": {
            "type": "boolean"
          },
          "supportsClientSearch": {
            "type": "boolean"
          },
          "isBeta": {
            "type": "boolean"
          },
          "hasExtendedScopes": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TimeAwayDto": {
        "type": "object",
        "properties": {
          "tenantUserCode": {
            "type": "string",
            "description": "The team member who is away",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "The first day away",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "The last day away (inclusive)",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "A period a team member is away, for flagging them when someone picks who to give work to.\nOnly the dates: never the kind of time off or its notes, which need the Time Off permission."
      },
      "TimeBillingLineMode": {
        "enum": [
          "Combined",
          "PerEntry",
          "Single"
        ],
        "type": "string",
        "example": "Combined"
      },
      "TimeEntryAllocationDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for the allocation",
            "nullable": true
          },
          "timeEntryCode": {
            "type": "string",
            "description": "The code of the time entry the allocation is against",
            "nullable": true
          },
          "clientBillingLineItemCode": {
            "type": "string",
            "description": "The code of the billing line item the time was billed on, or null for a pure write-off",
            "nullable": true
          },
          "settledValue": {
            "type": "number",
            "description": "WIP drawn down by this allocation",
            "format": "double"
          },
          "billedAmount": {
            "type": "number",
            "description": "What the client was charged for it",
            "format": "double"
          },
          "writeOffAmount": {
            "type": "number",
            "description": "Settled minus billed: positive is time written off, negative is a write-on",
            "format": "double"
          },
          "writeOffReason": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "notes": {
            "type": "string",
            "description": "Free-text context for the disposal",
            "nullable": true
          },
          "createdBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdDate": {
            "type": "string",
            "description": "When the disposal was recorded",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "One disposal event against a time entry: the WIP it drew down, what the client was charged\nfor it, and the difference (positive written off, negative written on). A pure write-off has\nno billing line item and a billed amount of zero."
      },
      "TimeEntryAllocationRequest": {
        "required": [
          "timeEntryCode"
        ],
        "type": "object",
        "properties": {
          "timeEntryCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the time entry"
          },
          "settledValue": {
            "maximum": 100000000,
            "minimum": 0,
            "type": "number",
            "description": "WIP to draw down on this entry. At most its open WIP (billable value minus what is already\nsettled); less leaves the rest open to bill later.",
            "format": "double"
          },
          "billedAmount": {
            "maximum": 100000000,
            "minimum": 0,
            "type": "number",
            "description": "What the client is charged for this entry. Ignored on a write-off (always 0 there).",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "An explicit per-entry allocation for the cherry-picking case: how much of the entry's open\nWIP to settle, and how much of the fee to attribute to it. When a bill request carries these,\nevery selected entry needs one and the billed amounts must sum to the fee."
      },
      "TimeEntryDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for the time entry",
            "nullable": true
          },
          "user": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "entryDate": {
            "type": "string",
            "description": "The day the work was done (format: yyyy-MM-dd)",
            "format": "date"
          },
          "durationMinutes": {
            "type": "integer",
            "description": "How long the work took, in minutes",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "When the work started (UTC) — populated for timer-logged entries, optional otherwise",
            "format": "date-time",
            "nullable": true
          },
          "endTime": {
            "type": "string",
            "description": "When the work ended (UTC) — populated for timer-logged entries, optional otherwise",
            "format": "date-time",
            "nullable": true
          },
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimerBlockDto"
            },
            "description": "The work blocks the entry was logged from, for timer-logged entries; empty for\nmanual entries. When present, StartTime, EndTime and DurationMinutes are derived\nfrom the blocks (span start, span end, summed working time) and are read-only —\nthe summed duration can be less than the span when the timer was paused.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "What the time was spent on",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "taskItem": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflowStep": {
            "$ref": "#/components/schemas/LinkedWorkflowStepDto"
          },
          "service": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "stage": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "isBillable": {
            "type": "boolean",
            "description": "Whether this time can be billed to the client"
          },
          "hourlyRate": {
            "type": "number",
            "description": "Charge-out rate per hour snapshotted on the entry, billable or not (non-billable time is valued\nagainst the job's fee budget, never billed)",
            "format": "double",
            "nullable": true
          },
          "costRate": {
            "type": "number",
            "description": "Internal cost rate per hour snapshotted on the entry from the user's rate effective on\nthe entry date. Null when none applied, or when the caller lacks the Cost Rates permission.",
            "format": "double",
            "nullable": true
          },
          "billableValue": {
            "type": "number",
            "description": "The entry's billable value: its minutes at the stamped rate, to the penny (0 with no rate, and 0 for non-billable time)",
            "format": "double"
          },
          "settledValue": {
            "type": "number",
            "description": "WIP disposed of so far across the entry's allocations, billed or written off",
            "format": "double"
          },
          "billedAmount": {
            "type": "number",
            "description": "What the client has been charged for this entry across its allocations",
            "format": "double"
          },
          "openWip": {
            "type": "number",
            "description": "WIP still open: BillableValue minus SettledValue",
            "format": "double"
          },
          "settlementState": {
            "$ref": "#/components/schemas/TimeEntrySettlementState"
          },
          "paymentApprovedDate": {
            "type": "string",
            "description": "When the entry was approved for payment to the team member (null until approved).\nCleared automatically when the entry is edited — a material change goes back\nthrough approval.",
            "format": "date-time",
            "nullable": true
          },
          "paymentApprovedBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "timePayRunCode": {
            "type": "string",
            "description": "The code of the pay run this entry was paid on (null until paid). Paid entries\ncan no longer be edited or deleted.",
            "nullable": true
          },
          "externalEventUid": {
            "type": "string",
            "description": "The external calendar meeting the entry was logged from (its occurrence UID), if any",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the entry was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the entry was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A recorded block of time worked by a team member"
      },
      "TimeEntryDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimeEntryDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TimeEntryRateChangeDto": {
        "type": "object",
        "properties": {
          "timeEntryCode": {
            "type": "string",
            "description": "The time entry's code",
            "nullable": true
          },
          "entryDate": {
            "type": "string",
            "description": "The day the time was logged against",
            "format": "date"
          },
          "userCode": {
            "type": "string",
            "description": "The team member who logged the time",
            "nullable": true
          },
          "userName": {
            "type": "string",
            "description": "The team member's name",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client the time is for",
            "nullable": true
          },
          "taskItemName": {
            "type": "string",
            "description": "The task the time is for",
            "nullable": true
          },
          "serviceName": {
            "type": "string",
            "description": "The library service the time is for, directly or through its task",
            "nullable": true
          },
          "durationMinutes": {
            "type": "integer",
            "description": "The time logged, in minutes",
            "format": "int32"
          },
          "currentHourlyRate": {
            "type": "number",
            "description": "The charge-out rate stamped on the entry now",
            "format": "double",
            "nullable": true
          },
          "newHourlyRate": {
            "type": "number",
            "description": "The charge-out rate the entry would get",
            "format": "double",
            "nullable": true
          },
          "currentCostRate": {
            "type": "number",
            "description": "The cost rate stamped on the entry now. Null for callers who cannot change cost rates.",
            "format": "double",
            "nullable": true
          },
          "newCostRate": {
            "type": "number",
            "description": "The cost rate the entry would get. Null for callers who cannot change cost rates.",
            "format": "double",
            "nullable": true
          },
          "isPaymentApproved": {
            "type": "boolean",
            "description": "Whether the entry is approved for payment. A changed cost rate clears the approval."
          }
        },
        "additionalProperties": false,
        "description": "One logged time entry whose stamped rates differ from the rates that apply now. Cost rates\nare only included for callers who can change them."
      },
      "TimeEntryRateRecalculationRequest": {
        "required": [
          "fromDate"
        ],
        "type": "object",
        "properties": {
          "fromDate": {
            "type": "string",
            "description": "The first entry date to include",
            "format": "date"
          },
          "userCode": {
            "maxLength": 100,
            "type": "string",
            "description": "Limits the entries to one team member",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Which logged time to re-apply the current rates to: unpaid entries dated from FromDate,\noptionally for one team member."
      },
      "TimeEntryRateRecalculationResultDto": {
        "type": "object",
        "properties": {
          "updatedCount": {
            "type": "integer",
            "description": "How many entries were updated. Entries paid since the preview, or whose rates already\nmatch, are left out.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "The outcome of re-applying rates to logged time"
      },
      "TimeEntrySettlementState": {
        "enum": [
          "Open",
          "PartSettled",
          "Settled"
        ],
        "type": "string",
        "example": "Open"
      },
      "TimeEntrySortField": {
        "enum": [
          "EntryDate",
          "DurationMinutes",
          "ClientName",
          "UserName",
          "IsBillable"
        ],
        "type": "string",
        "example": "EntryDate"
      },
      "TimeEntryStageOptionsDto": {
        "type": "object",
        "properties": {
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeAndNameDto"
            },
            "description": "The service's stages, in board order",
            "nullable": true
          },
          "defaultStageCode": {
            "type": "string",
            "description": "The stage a new entry takes when none is chosen",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The service stages a time entry can be logged in, in board order, and the one it defaults to: the\nstage the task last moved its service to, else the service's current stage. Empty when the entry's\nservice has no stages."
      },
      "TimeImportAnalysisDto": {
        "type": "object",
        "properties": {
          "totalRows": {
            "type": "integer",
            "description": "Number of data rows in the file (usable or not)",
            "format": "int32"
          },
          "fromDate": {
            "type": "string",
            "description": "The earliest entry date in the file; null when no row has a usable date",
            "format": "date",
            "nullable": true
          },
          "toDate": {
            "type": "string",
            "description": "The latest entry date in the file; null when no row has a usable date",
            "format": "date",
            "nullable": true
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimeImportRowDto"
            },
            "description": "The parsed rows, in file order",
            "nullable": true
          },
          "teamMembers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimeImportTeamMemberDto"
            },
            "description": "The distinct team member names in the file, most rows first",
            "nullable": true
          },
          "clients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimeImportClientDto"
            },
            "description": "The distinct client names in the file, most rows first",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Result of analysing an uploaded time CSV: the parsed rows for review plus the distinct\nteam member and client names in the file, each with a suggested match, so the user maps\nnames once rather than row by row. Returned by the analyze endpoint; the RowIds are the\nkeys used in the import selections."
      },
      "TimeImportClientDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name as it appears in the file",
            "nullable": true
          },
          "rowCount": {
            "type": "integer",
            "description": "How many rows carry this name",
            "format": "int32"
          },
          "suggestedClientCode": {
            "type": "string",
            "description": "The code of the matching client, to prefill the mapping; null when none",
            "nullable": true
          },
          "suggestedClientName": {
            "type": "string",
            "description": "The name of the matching client; null when none",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A distinct client name found in a time CSV"
      },
      "TimeImportResultDto": {
        "type": "object",
        "properties": {
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimeImportRowResultDto"
            },
            "description": "Per-row outcomes, in selection order",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of a time CSV import (or of one batch of it — the frontend imports large\nfiles in batches and adds the results up)"
      },
      "TimeImportRowDto": {
        "type": "object",
        "properties": {
          "rowId": {
            "type": "string",
            "description": "Stable key for this row within the file (\"row-{n}\")",
            "nullable": true
          },
          "entryDate": {
            "type": "string",
            "description": "The day the work was done; null only for skipped rows without a usable date",
            "format": "date",
            "nullable": true
          },
          "teamMemberName": {
            "type": "string",
            "description": "The team member name as it appears in the file",
            "nullable": true
          },
          "clientName": {
            "type": "string",
            "description": "The client name as it appears in the file; null when the row has no client",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "The start time of day from the file; null when absent",
            "format": "time",
            "nullable": true
          },
          "endTime": {
            "type": "string",
            "description": "The end time of day from the file; null when absent",
            "format": "time",
            "nullable": true
          },
          "durationMinutes": {
            "type": "integer",
            "description": "The duration in minutes: the file's minutes, or hours converted, or the start–end span.\nNull only for skipped rows without a usable duration.",
            "format": "int32",
            "nullable": true
          },
          "isBillable": {
            "type": "boolean",
            "description": "Whether the entry will import as billable: the file's value, or the practice's\nbillable-by-default setting when the file has none"
          },
          "description": {
            "type": "string",
            "description": "The description that will be written: the file's notes with any task, category,\nproject or tag text not already present appended, so nothing in the file is lost",
            "nullable": true
          },
          "isDuplicate": {
            "type": "boolean",
            "description": "Whether an identical entry (same team member, date, duration and description)\nalready exists — importing it would produce a duplicate"
          },
          "defaultSelected": {
            "type": "boolean",
            "description": "Whether the row should be pre-ticked in the review grid"
          },
          "skipReason": {
            "type": "string",
            "description": "Why the row cannot be imported (e.g. \"Missing Date\", \"Invalid Duration\"); null for usable rows",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single time entry parsed from an uploaded time CSV, ready for user review"
      },
      "TimeImportRowResultDto": {
        "type": "object",
        "properties": {
          "rowId": {
            "type": "string",
            "description": "The RowId from the import selection",
            "nullable": true
          },
          "entryDate": {
            "type": "string",
            "description": "The entry date from the row, for identifying failures",
            "format": "date",
            "nullable": true
          },
          "teamMemberName": {
            "type": "string",
            "description": "The team member name from the row, for identifying failures",
            "nullable": true
          },
          "success": {
            "type": "boolean",
            "description": "Whether the row imported successfully"
          },
          "timeEntryCode": {
            "type": "string",
            "description": "The code of the created time entry",
            "nullable": true
          },
          "error": {
            "type": "string",
            "description": "Why the row failed, when Success is false",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of importing a single time CSV row"
      },
      "TimeImportTeamMemberDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name as it appears in the file",
            "nullable": true
          },
          "rowCount": {
            "type": "integer",
            "description": "How many rows carry this name",
            "format": "int32"
          },
          "suggestedUserCode": {
            "type": "string",
            "description": "The code of the tenant user whose name matches, to prefill the mapping; null when none",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A distinct team member name found in a time CSV"
      },
      "TimeOffDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "tenantUserCode": {
            "type": "string",
            "description": "The team member who is off",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "The first day off",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "The last day off (inclusive)",
            "format": "date"
          },
          "type": {
            "$ref": "#/components/schemas/TimeOffType"
          },
          "minutesPerDay": {
            "type": "integer",
            "description": "Minutes taken off each day, for part days. Null means the whole day",
            "format": "int32",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A period a team member is off: holiday, sickness or other leave. Their expected hours drop on\neach of its days, by SodiumHQ.DTOs.TimeTracking.TimeOffDto.MinutesPerDay or to nothing for a whole day."
      },
      "TimeOffRequest": {
        "required": [
          "endDate",
          "startDate",
          "type"
        ],
        "type": "object",
        "properties": {
          "tenantUserCode": {
            "type": "string",
            "description": "The team member who is off. Empty for the caller",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "The first day off",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "The last day off (inclusive). The same as the start date for a single day",
            "format": "date"
          },
          "type": {
            "$ref": "#/components/schemas/TimeOffType"
          },
          "minutesPerDay": {
            "maximum": 1440,
            "minimum": 1,
            "type": "integer",
            "description": "Minutes taken off each day, for part days (a half day is 225 on a 7.5 hour day). Null means\nthe whole day",
            "format": "int32",
            "nullable": true
          },
          "notes": {
            "maxLength": 500,
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Records or replaces a period of time off. Leave SodiumHQ.DTOs.TimeTracking.TimeOffRequest.TenantUserCode empty for your\nown; anyone else's needs the Time Off permission."
      },
      "TimeOffType": {
        "enum": [
          "Holiday",
          "Sickness",
          "Other"
        ],
        "type": "string",
        "example": "Holiday"
      },
      "TimePayRunDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique code for the pay run",
            "nullable": true
          },
          "user": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "createdBy": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "fromEntryDate": {
            "type": "string",
            "description": "Entry date of the earliest entry in the run",
            "format": "date"
          },
          "toEntryDate": {
            "type": "string",
            "description": "Entry date of the latest entry in the run",
            "format": "date"
          },
          "totalMinutes": {
            "type": "integer",
            "description": "Total minutes paid on the run",
            "format": "int32"
          },
          "totalAmount": {
            "type": "number",
            "description": "Total amount paid: the minutes per distinct cost rate valued at that rate, to the penny",
            "format": "double"
          },
          "entryCount": {
            "type": "integer",
            "description": "Number of time entries paid on the run",
            "format": "int32"
          },
          "createdDate": {
            "type": "string",
            "description": "When the payment was recorded",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "A payment of tracked time to one team member — the receipt for a batch of their time\nentries paid at the cost rates stamped on the entries. Totals were computed when the\nrun was created and never change; deleting the run releases its entries back to approved."
      },
      "TimePayRunDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimePayRunDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TimePayRunSortField": {
        "enum": [
          "CreatedDate",
          "ToEntryDate",
          "TotalAmount",
          "UserName"
        ],
        "type": "string",
        "example": "CreatedDate"
      },
      "TimeRecordingSettingsDto": {
        "type": "object",
        "properties": {
          "timeTrackingEnabled": {
            "type": "boolean",
            "description": "Whether time tracking is enabled for this tenant.\nWhen disabled, no time tracking UI is shown anywhere in the app."
          },
          "requireClientOrTask": {
            "type": "boolean",
            "description": "When true, every time entry must be linked to a client or a task"
          },
          "billableByDefault": {
            "type": "boolean",
            "description": "When true, new time entries and timers start as billable"
          },
          "defaultHourlyRate": {
            "type": "number",
            "description": "Default charge-out rate per hour for billable time entries,\nused when the team member has no rate of their own",
            "format": "double",
            "nullable": true
          },
          "defaultCostRate": {
            "type": "number",
            "description": "Default cost rate per hour, used when the team member has no cost rate of their own.\nMasked to null for callers without the Cost Rates view permission",
            "format": "double",
            "nullable": true
          },
          "billingLineMode": {
            "$ref": "#/components/schemas/TimeBillingLineMode"
          },
          "autoTimerEnabled": {
            "type": "boolean",
            "description": "When true, starting a workflow step (or a task with no workflow) starts a timer\nfor the acting user linked to it, and completing or skipping it stops the linked\ntimer and logs the time"
          },
          "workTypeRatePrecedence": {
            "$ref": "#/components/schemas/WorkTypeRatePrecedence"
          },
          "budgetWarningPercent": {
            "type": "integer",
            "description": "The share of a job budget, in percent, at which its time is shown as near the line and the\nmanager is warned (docs/features/ClientJobBudgets/PLAN.md D7)",
            "format": "int32"
          },
          "budgetsEnabled": {
            "type": "boolean",
            "description": "Whether the practice uses job budgets. Off by default: budget progress, the Budgets report, budget\nalerts and Cost & Profit's price and fee budget are hidden. Switching it off keeps every standard\nand client figure, so switching it back on restores them."
          },
          "showBudgetOnTasks": {
            "type": "boolean",
            "description": "Whether a task's page shows the Budget card while budgets are on. On by default; off only hides\nthe card (the task budget route still answers), so the practice can keep budgets to services,\nclients and reports."
          },
          "feeBudgetsEnabled": {
            "type": "boolean",
            "description": "Whether the practice uses fee budgets beside hours (ClientJobBudgets R3). Off by default; off means\nnothing about money anywhere: no fee figures, fee columns, fee alerts or value of time, and the fee\nroutes refuse. Every fee figure is kept, so switching it back on restores them. The Fee Budgets\npermission still decides who sees them while on."
          }
        },
        "additionalProperties": false,
        "description": "Tenant-level settings for time recording"
      },
      "TimeWipReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/TimeWipSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/TimeWipRowDtoPagedResult"
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The WIP Value report: a point-in-time snapshot of billable time not yet billed or written\noff, valued at the stamped charge-out rates and aged from the day it was worked. Distinct\nfrom WIP / Ageing, which is about open tasks. Recovery is measured against Sodium's billing\nlines: time allocations, plus lines attributed to the job that carry no time (fixed fees,\non-account and progress bills). Time billed before the allocation model existed reads as\nfully recovered."
      },
      "TimeWipRowDto": {
        "type": "object",
        "properties": {
          "groupCode": {
            "type": "string",
            "description": "The group's code; null for the \"No client\" / \"No service\" row",
            "nullable": true
          },
          "groupName": {
            "type": "string",
            "description": "The group's display name",
            "nullable": true
          },
          "client": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "billableValue": {
            "type": "number",
            "description": "All-time billable value of the group's billable time at the stamped rates",
            "format": "double"
          },
          "settledValue": {
            "type": "number",
            "description": "WIP settled across the group's allocations, billed or written off",
            "format": "double"
          },
          "billedAmount": {
            "type": "number",
            "description": "What clients were charged across the group's time allocations",
            "format": "double"
          },
          "billedOnAccount": {
            "type": "number",
            "description": "Billed on lines attributed to the group's service(s) that carry no time: fixed fees,\non-account and progress bills. Null for the User grouping.",
            "format": "double",
            "nullable": true
          },
          "writtenOffAmount": {
            "type": "number",
            "description": "Settled minus billed on time allocations: time written off (negative is written on)",
            "format": "double"
          },
          "recoveryRate": {
            "type": "number",
            "description": "Everything billed (time allocations plus on-account lines) as a share of the billable value,\nas a percentage; null when there is no billable value",
            "format": "double",
            "nullable": true
          },
          "openWip": {
            "type": "number",
            "description": "WIP still open",
            "format": "double"
          },
          "openEntryCount": {
            "type": "integer",
            "description": "Billable entries with WIP still open",
            "format": "int32"
          },
          "unratedEntryCount": {
            "type": "integer",
            "description": "Billable entries with no rate",
            "format": "int32"
          },
          "oldestAgeDays": {
            "type": "integer",
            "description": "Days since the oldest entry with open WIP was worked; null when nothing is open",
            "format": "int32",
            "nullable": true
          },
          "open0To30": {
            "type": "number",
            "description": "Open WIP on entries worked within the last 30 days",
            "format": "double"
          },
          "open31To60": {
            "type": "number",
            "description": "Open WIP on entries worked 31 to 60 days ago",
            "format": "double"
          },
          "open61To90": {
            "type": "number",
            "description": "Open WIP on entries worked 61 to 90 days ago",
            "format": "double"
          },
          "openOver90": {
            "type": "number",
            "description": "Open WIP on entries worked more than 90 days ago",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "One group's row on the WIP Value report: a client, client service or team member"
      },
      "TimeWipRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimeWipRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "TimeWipSummaryDto": {
        "type": "object",
        "properties": {
          "openWip": {
            "type": "number",
            "description": "Open WIP across every billable entry",
            "format": "double"
          },
          "openEntryCount": {
            "type": "integer",
            "description": "Billable entries with WIP still open",
            "format": "int32"
          },
          "openMinutes": {
            "type": "integer",
            "description": "Minutes behind the open WIP",
            "format": "int32"
          },
          "unratedEntryCount": {
            "type": "integer",
            "description": "Billable entries with no rate: time that cannot be valued until a rate is set",
            "format": "int32"
          },
          "oldestAgeDays": {
            "type": "integer",
            "description": "Days since the oldest entry with open WIP was worked; null when nothing is open",
            "format": "int32",
            "nullable": true
          },
          "open0To30": {
            "type": "number",
            "description": "Open WIP on entries worked within the last 30 days",
            "format": "double"
          },
          "open31To60": {
            "type": "number",
            "description": "Open WIP on entries worked 31 to 60 days ago",
            "format": "double"
          },
          "open61To90": {
            "type": "number",
            "description": "Open WIP on entries worked 61 to 90 days ago",
            "format": "double"
          },
          "openOver90": {
            "type": "number",
            "description": "Open WIP on entries worked more than 90 days ago",
            "format": "double"
          },
          "groupCount": {
            "type": "integer",
            "description": "Number of rows (groups) in the report",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Headline aggregates for the WIP Value report"
      },
      "TimerBlockDto": {
        "type": "object",
        "properties": {
          "startedAt": {
            "type": "string",
            "description": "When this block of work started (UTC), for wall-clock blocks",
            "format": "date-time",
            "nullable": true
          },
          "endedAt": {
            "type": "string",
            "description": "When this block of work ended (UTC), or null while it is still running",
            "format": "date-time",
            "nullable": true
          },
          "minutes": {
            "type": "integer",
            "description": "The block's duration in minutes, for blocks recorded as an amount of time\nrather than a wall-clock span",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "One block of work on a timer or time entry — either a wall-clock span (start\nand end time) or a plain number of minutes. When Minutes is set it is the\nblock's duration and any times are just context. A block with a start but no\nend and no minutes is still running; no open block means the timer is paused."
      },
      "TrackExternalFileItemDto": {
        "type": "object",
        "properties": {
          "externalFileId": {
            "type": "string",
            "description": "The platform-specific file identifier (e.g., Drive file ID)",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "description": "The file name from the provider — also used to derive the document title",
            "nullable": true
          },
          "fileSize": {
            "type": "integer",
            "description": "File size in bytes",
            "format": "int64"
          }
        },
        "additionalProperties": false,
        "description": "One external file to track within a bulk track request."
      },
      "TrackExternalFileRequest": {
        "type": "object",
        "properties": {
          "externalFileId": {
            "type": "string",
            "description": "The platform-specific file identifier (e.g., Box file ID)",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "description": "The original file name from the provider",
            "nullable": true
          },
          "fileSize": {
            "type": "integer",
            "description": "File size in bytes",
            "format": "int64"
          },
          "title": {
            "type": "string",
            "description": "The title for the document in Sodium",
            "nullable": true
          },
          "summary": {
            "type": "string",
            "description": "A brief summary or description",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "The date the document is dated",
            "format": "date"
          },
          "documentCategoryCode": {
            "type": "string",
            "description": "The document category code",
            "nullable": true
          },
          "visibleInClientPortal": {
            "type": "boolean",
            "description": "Whether this document is visible in the client portal. Defaults to false: tracking only publishes a file when asked to."
          },
          "portalFolderPath": {
            "maxLength": 2000,
            "type": "string",
            "description": "Folder path controlling where the document appears in the client portal, \"/\" separated.\nUsually the file's folder in external storage, so the portal mirrors the storage layout.\nNull or empty for the portal root.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to track an existing external file in our system, creating a ClientDocument\nrecord that references the file by its platform-specific ID. No file upload required."
      },
      "TriageBreakdownRowDto": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "string",
            "description": "The effective status, as the conversation list shows it: the conversation's own, else the first\nactive Done status for one from before triage was switched on, else the mailbox default. Null\nwhen none of those gives one.",
            "nullable": true
          },
          "assigneeCode": {
            "type": "string",
            "description": "The assignee; null for unassigned conversations",
            "nullable": true
          },
          "count": {
            "type": "integer",
            "description": "How many conversations have this status and assignee",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "How many Inbox conversations, across the caller's mailboxes that have triage on, sit at one effective\ntriage status with one assignee. Every conversation counts, open or done: the caller decides which\nstatuses it shows."
      },
      "TriggerMtdAdjustableSummaryRequest": {
        "required": [
          "accountingPeriodEndDate",
          "accountingPeriodStartDate",
          "businessId",
          "incomeSourceType"
        ],
        "type": "object",
        "properties": {
          "businessId": {
            "maxLength": 20,
            "minLength": 1,
            "type": "string",
            "description": "HMRC's identifier for the income source."
          },
          "incomeSourceType": {
            "$ref": "#/components/schemas/MtdIncomeSourceType"
          },
          "accountingPeriodStartDate": {
            "type": "string",
            "description": "Start of the accounting period to summarise.",
            "format": "date"
          },
          "accountingPeriodEndDate": {
            "type": "string",
            "description": "End of the accounting period to summarise. Must have passed.",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "Asks HMRC to generate a new adjustable summary for an income source and accounting period.\nThe period must have ended."
      },
      "TriggerMtdTaxReturnCalculationRequest": {
        "type": "object",
        "properties": {
          "declarationType": {
            "$ref": "#/components/schemas/HmrcFinalDeclarationType"
          }
        },
        "additionalProperties": false,
        "description": "Asks HMRC to work out the calculation a tax return declares.\n            \nA tax return does not declare whatever calculation HMRC last ran. It declares one triggered for\nthat purpose: as an intent to finalise for the return itself, or as an intent to amend for a\nchange to a return already filed. The in-year estimates the quarterly updates produce are never\ncandidates, so until this has been run for a year there is nothing to send."
      },
      "UkDividendsIncome": {
        "type": "object",
        "properties": {
          "ukDividends": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherUkDividends": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyAnnualAdjustments": {
        "type": "object",
        "properties": {
          "balancingCharge": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "privateUseAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "businessPremisesRenovationAllowanceBalancingCharges": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "nonResidentLandlord": {
            "type": "boolean",
            "nullable": true
          },
          "rentARoom": {
            "$ref": "#/components/schemas/UkPropertyAnnualRentARoom"
          }
        },
        "additionalProperties": false
      },
      "UkPropertyAnnualAllowances": {
        "type": "object",
        "properties": {
          "annualInvestmentAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "businessPremisesRenovationAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherCapitalAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "costOfReplacingDomesticItems": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "zeroEmissionsCarAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "propertyIncomeAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "firstYearAllowanceOnPlantAndMachinery": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "structuredBuildingAllowance": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StructuredBuildingAllowanceItem"
            },
            "nullable": true
          },
          "enhancedStructuredBuildingAllowance": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StructuredBuildingAllowanceItem"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyAnnualRentARoom": {
        "type": "object",
        "properties": {
          "jointlyLet": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyAnnualSubmission": {
        "type": "object",
        "properties": {
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "adjustments": {
            "$ref": "#/components/schemas/UkPropertyAnnualAdjustments"
          },
          "allowances": {
            "$ref": "#/components/schemas/UkPropertyAnnualAllowances"
          }
        },
        "additionalProperties": false
      },
      "UkPropertyBsas": {
        "type": "object",
        "properties": {
          "metadata": {
            "$ref": "#/components/schemas/BsasMetadata"
          },
          "inputs": {
            "$ref": "#/components/schemas/BsasInputs"
          },
          "adjustableSummaryCalculation": {
            "$ref": "#/components/schemas/UkPropertyBsasCalculation"
          },
          "adjustments": {
            "$ref": "#/components/schemas/UkPropertyBsasAdjustments"
          },
          "adjustedSummaryCalculation": {
            "$ref": "#/components/schemas/UkPropertyBsasCalculation"
          }
        },
        "additionalProperties": false
      },
      "UkPropertyBsasAdditions": {
        "type": "object",
        "properties": {
          "privateUseAdjustment": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "balancingCharge": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "bpraBalancingCharge": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyBsasAdjustmentInputs": {
        "type": "object",
        "properties": {
          "income": {
            "$ref": "#/components/schemas/UkPropertyBsasIncome"
          },
          "expenses": {
            "$ref": "#/components/schemas/UkPropertyBsasExpenses"
          }
        },
        "additionalProperties": false,
        "description": "The property adjustment figures, as deltas."
      },
      "UkPropertyBsasAdjustments": {
        "type": "object",
        "properties": {
          "income": {
            "$ref": "#/components/schemas/UkPropertyBsasIncome"
          },
          "expenses": {
            "$ref": "#/components/schemas/UkPropertyBsasExpenses"
          },
          "zeroAdjustments": {
            "type": "boolean",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyBsasCalculation": {
        "type": "object",
        "properties": {
          "totalIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "income": {
            "$ref": "#/components/schemas/UkPropertyBsasIncome"
          },
          "totalExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "expenses": {
            "$ref": "#/components/schemas/UkPropertyBsasExpenses"
          },
          "netProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "netLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "totalAdditions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "additions": {
            "$ref": "#/components/schemas/UkPropertyBsasAdditions"
          },
          "totalDeductions": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "deductions": {
            "$ref": "#/components/schemas/UkPropertyBsasDeductions"
          },
          "taxableProfit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "adjustedIncomeTaxLoss": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyBsasDeductions": {
        "type": "object",
        "properties": {
          "zeroEmissionGoods": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "annualInvestmentAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "costOfReplacingDomesticItems": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "businessPremisesRenovationAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "propertyAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherCapitalAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "rarReliefClaimed": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "electricChargePointAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "structuredBuildingAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "enhancedStructuredBuildingAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "zeroEmissionsCarAllowance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "firstYearAllowanceOnPlantAndMachinery": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyBsasExpenses": {
        "type": "object",
        "properties": {
          "premisesRunningCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "repairsAndMaintenance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "financialCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "professionalFees": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "costOfServices": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "residentialFinancialCost": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "broughtFwdResidentialFinancialCost": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "other": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "travelCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "consolidatedExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyBsasIncome": {
        "type": "object",
        "properties": {
          "totalRentsReceived": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "premiumsOfLeaseGrant": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "reversePremiums": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherPropertyIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "rarRentReceived": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyCumulativeSummary": {
        "type": "object",
        "properties": {
          "fromDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "toDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "submittedOn": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "ukProperty": {
            "$ref": "#/components/schemas/UkPropertyFigures"
          }
        },
        "additionalProperties": false
      },
      "UkPropertyExpenses": {
        "type": "object",
        "properties": {
          "premisesRunningCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "repairsAndMaintenance": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "financialCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "professionalFees": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "costOfServices": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "other": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "residentialFinancialCost": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "travelCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "residentialFinancialCostsCarriedForward": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "rentARoom": {
            "$ref": "#/components/schemas/UkPropertyRentARoomExpenses"
          },
          "consolidatedExpenses": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyFigures": {
        "type": "object",
        "properties": {
          "income": {
            "$ref": "#/components/schemas/UkPropertyIncome"
          },
          "expenses": {
            "$ref": "#/components/schemas/UkPropertyExpenses"
          }
        },
        "additionalProperties": false
      },
      "UkPropertyIncome": {
        "type": "object",
        "properties": {
          "premiumsOfLeaseGrant": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "reversePremiums": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "periodAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "taxDeducted": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "otherIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "rentARoom": {
            "$ref": "#/components/schemas/UkPropertyRentARoomIncome"
          }
        },
        "additionalProperties": false
      },
      "UkPropertyRentARoomExpenses": {
        "type": "object",
        "properties": {
          "amountClaimed": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UkPropertyRentARoomIncome": {
        "type": "object",
        "properties": {
          "rentsReceived": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UnbilledTimeClientDto": {
        "type": "object",
        "properties": {
          "client": {
            "$ref": "#/components/schemas/ClientRefDto"
          },
          "unbilledMinutes": {
            "type": "integer",
            "description": "Total unbilled billable minutes for the client, including entries with no hourly rate",
            "format": "int32"
          },
          "entryCount": {
            "type": "integer",
            "description": "Number of unbilled billable entries for the client, including entries with no hourly rate",
            "format": "int32"
          },
          "unbilledAmount": {
            "type": "number",
            "description": "Value of the unbilled time excluding VAT, counting only entries that carry an hourly rate.\nComputed the same way the billing line items are, so it previews them faithfully.",
            "format": "double"
          },
          "oldestEntryDate": {
            "type": "string",
            "description": "Entry date of the client's oldest unbilled billable entry — how stale this WIP is",
            "format": "date",
            "nullable": true
          },
          "unratedEntryCount": {
            "type": "integer",
            "description": "How many of the unbilled entries have no hourly rate, and so cannot be billed until one is set",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A client with unbilled billable time, and how much of it there is. The figures reflect\nwhatever date window and team member the request asked for, so they always agree with\nthe entries behind them."
      },
      "UnbilledTimeClientDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UnbilledTimeClientDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "UnbilledTimeClientSortField": {
        "enum": [
          "ClientName",
          "UnbilledMinutes",
          "UnbilledAmount",
          "OldestEntryDate"
        ],
        "type": "string",
        "example": "ClientName"
      },
      "UngroupedSenderPreviewDto": {
        "type": "object",
        "properties": {
          "splitEmailCount": {
            "type": "integer",
            "description": "How many emails already in the mailbox would be split into conversations of their own",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "What adding an address or domain to a mailbox's ungrouped senders would do to the emails already in it"
      },
      "UngroupedSendersDto": {
        "required": [
          "senders"
        ],
        "type": "object",
        "properties": {
          "senders": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The addresses and domains, lowercased. Sent in a PUT, it replaces the list (empty clears it); an\naddress or domain added also splits its emails already in the mailbox."
          },
          "splitEmailCount": {
            "type": "integer",
            "description": "On a response to a change: how many emails already in the mailbox were split into conversations of\ntheir own. Ignored in a request.",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A mailbox's ungrouped senders: addresses (noreply@hmrc.gov.uk) and domains (hmrc.gov.uk, which also\ncovers its subdomains) whose emails each arrive as a conversation of their own, instead of joining the\nthread Outlook or Gmail puts them in. Stored in the email service."
      },
      "UnlistedSharesDisposal": {
        "type": "object",
        "properties": {
          "numberOfDisposals": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "assetDescription": {
            "type": "string",
            "nullable": true
          },
          "companyName": {
            "type": "string",
            "nullable": true
          },
          "companyRegistrationNumber": {
            "type": "string",
            "nullable": true
          },
          "acquisitionDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "disposalDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "disposalProceeds": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "allowableCosts": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsWithBadr": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsWithInv": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsBeforeLosses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "losses": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "claimOrElectionCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "gainsReportedOnRtt": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsExceedingLifetimeLimit": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "gainsUnderSeis": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "lossUsedAgainstGeneralIncome": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "eisOrSeisReliefDueCurrentYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "lossesUsedAgainstGeneralIncomePreviousYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "eisOrSeisReliefDuePreviousYear": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "rttTaxPaid": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UnpaidTimeUserDto": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "isFormerMember": {
            "type": "boolean",
            "description": "True when the member is no longer active in the tenant and only appears\nbecause they still have unpaid time"
          },
          "unpaidMinutes": {
            "type": "integer",
            "description": "Total unpaid minutes for the member, including entries with no cost rate",
            "format": "int32"
          },
          "entryCount": {
            "type": "integer",
            "description": "Number of unpaid entries for the member, including entries with no cost rate",
            "format": "int32"
          },
          "unpaidAmount": {
            "type": "number",
            "description": "Value of the unpaid time, counting only entries that carry a cost rate.\nComputed the same way pay runs are, so it previews them faithfully.",
            "format": "double"
          },
          "approvedMinutes": {
            "type": "integer",
            "description": "Of the unpaid minutes, the minutes already approved for payment",
            "format": "int32"
          },
          "approvedAmount": {
            "type": "number",
            "description": "Of the unpaid amount, the value already approved for payment (cost-rated entries only)",
            "format": "double"
          },
          "oldestEntryDate": {
            "type": "string",
            "description": "Entry date of the member's oldest unpaid entry — how far back the practice owes them",
            "format": "date",
            "nullable": true
          },
          "uncostedEntryCount": {
            "type": "integer",
            "description": "How many of the unpaid entries have no cost rate, and so cannot be paid until the\nmember is given one",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A team member the practice pays for tracked time, and how much of their time is\nstill unpaid. The figures reflect whatever date window the request asked for, so\nthey always agree with the entries behind them. Cost applies to all tracked time,\nso billable and non-billable minutes both count."
      },
      "UnpaidTimeUserDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UnpaidTimeUserDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "UnpaidTimeUserSortField": {
        "enum": [
          "UserName",
          "UnpaidMinutes",
          "UnpaidAmount",
          "OldestEntryDate"
        ],
        "type": "string",
        "example": "UserName"
      },
      "UpcomingDeadlineBucketDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Bucket key for deep-links: \"overdue\", \"0-7\", \"8-14\", \"15-30\", or \"31+\".",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name for the bucket.",
            "nullable": true
          },
          "count": {
            "type": "integer",
            "description": "Open tasks whose deadline falls in this bucket.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One days-remaining bucket of the upcoming-deadlines snapshot."
      },
      "UpdateAiSettingsRequest": {
        "type": "object",
        "properties": {
          "useCustomKey": {
            "type": "boolean",
            "description": "Whether to use a custom OpenAI API key instead of the shared platform key"
          },
          "customKey": {
            "type": "string",
            "description": "The custom OpenAI API key (only used if UseCustomKey is true)",
            "nullable": true
          },
          "model": {
            "type": "string",
            "description": "The OpenRouter model identifier to use (e.g., \"openai/gpt-4o-mini\", or \"default\" for platform default). Must be one of the models from the list of AI models, unless the practice uses its own key, which may use any model.",
            "nullable": true
          },
          "region": {
            "$ref": "#/components/schemas/AiRegion"
          },
          "useBritishEnglish": {
            "type": "boolean",
            "description": "Whether to use British English spelling and conventions in AI-generated content"
          },
          "context": {
            "$ref": "#/components/schemas/AiContext"
          },
          "modelServicesScheduleContentCode": {
            "type": "string",
            "description": "Code of the content block that provides context/instructions for AI when generating service schedule descriptions",
            "nullable": true
          },
          "modelProposalsContentCode": {
            "type": "string",
            "description": "Code of the content block that provides context/instructions for AI when generating proposal content",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating AI settings for a tenant"
      },
      "UpdateAmlContactRequest": {
        "type": "object",
        "properties": {
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "middleName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "nullable": true
          },
          "companiesHousePersonalCode": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update a contact in the AML platform. All fields are optional — only provided fields are sent."
      },
      "UpdateApiKeyRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The friendly name for this API key"
          },
          "tenantCode": {
            "type": "string",
            "description": "The tenant to scope this key to (required when scoping to a role)",
            "nullable": true
          },
          "systemRoleType": {
            "$ref": "#/components/schemas/SystemRole"
          },
          "roleCode": {
            "type": "string",
            "description": "The code of the custom role to scope to. Supply either this or SystemRoleType, not both.",
            "nullable": true
          },
          "isSendBlocked": {
            "type": "boolean",
            "description": "Block this key from every endpoint that sends a message (email, SMS, WhatsApp), whatever\nits role allows: it can still create and edit drafts. Defaults to false."
          }
        },
        "additionalProperties": false,
        "description": "Request to update an API key. This is a full replacement of the key's name and scope:\nomit the scope fields to make (or keep) the key unscoped, or supply a tenant + role to\nscope it. The key value itself never changes."
      },
      "UpdateBillableServiceRequest": {
        "required": [
          "categoryCode",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the service"
          },
          "description": {
            "type": "string",
            "description": "The description of the service",
            "nullable": true
          },
          "clientTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "The types of clients this service is applicable to.\nAn empty list means the service is applicable to all client types.",
            "nullable": true
          },
          "agentAuthorisations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentAuthorisationType"
            },
            "description": "The HMRC agent authorisation types relevant to this service",
            "nullable": true
          },
          "requiredProducts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SodiumProduct"
            },
            "description": "The Sodium products this service is powered by. A client taking the service gets each\nproduct's tab on their record.",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "Indicates whether this service is archived (inactive)"
          },
          "accountingCode": {
            "maxLength": 20,
            "minLength": 0,
            "type": "string",
            "description": "The accounting code for this service (max 20 characters)",
            "nullable": true
          },
          "defaultManagedByUserCode": {
            "type": "string",
            "description": "The code of the user who is the default manager for this service",
            "nullable": true
          },
          "serviceScheduleContentCode": {
            "type": "string",
            "description": "The code of the content block to use for service schedule",
            "nullable": true
          },
          "proposalContentCode": {
            "type": "string",
            "description": "The code of the content block to use for proposals",
            "nullable": true
          },
          "categoryCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the category for this service"
          },
          "vatRate": {
            "$ref": "#/components/schemas/VatRate"
          },
          "pricingMode": {
            "$ref": "#/components/schemas/ServicePricingMode"
          },
          "pricingTiers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServicePricingTierDto"
            },
            "description": "Custom pricing tiers. Required when PricingMode = CustomTiers.",
            "nullable": true
          },
          "showKanbanBoard": {
            "type": "boolean",
            "description": "Whether this service should appear on the Boards kanban view"
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServiceStageDto"
            },
            "description": "User-defined workflow stages for this service",
            "nullable": true
          },
          "pricing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillableServicePricingOptionDto"
            },
            "description": "The pricing options for this service",
            "nullable": true
          },
          "pricingFactors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PricingFactorDto"
            },
            "description": "The pricing factors that can affect the service pricing calculations",
            "nullable": true
          },
          "pcrItemCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of professional clearance request items for this service",
            "nullable": true
          },
          "invoiceLineDescriptionTemplate": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "Smart name token template for invoice line descriptions (e.g. \"{{ ServiceName }} - {{ Month }} {{ Year }}\")",
            "nullable": true
          },
          "setupFee": {
            "type": "number",
            "description": "Optional one-off setup fee charged when the service is first billed for a client.\nNull means no setup fee.",
            "format": "double",
            "nullable": true
          },
          "pricingBasis": {
            "$ref": "#/components/schemas/PricingBasis"
          },
          "unitName": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The unit label for PerUnit pricing (e.g. \"employee\", \"timesheet\").\nRequired when PricingBasis is PerUnit, must be blank otherwise.",
            "nullable": true
          },
          "quantityVariesPerPeriod": {
            "type": "boolean",
            "description": "Whether the billed quantity is expected to change from period to period. When true (default),\ngenerated billing lines for non-Fixed services are always created Pending so the quantity can be\nconfirmed before invoicing, regardless of the approval settings. Used as the default when\nassigning the service to a client. Ignored when PricingBasis is Fixed."
          },
          "defaultUnitQuantity": {
            "maximum": 9999999,
            "minimum": 0,
            "type": "number",
            "description": "The typical quantity per billing period, used as the default when assigning the service to a\nclient. Null means the volume is unknown. Ignored when PricingBasis is Fixed.",
            "format": "double",
            "nullable": true
          },
          "supportsCatchUpFees": {
            "type": "boolean",
            "description": "Whether a catch-up fee can be agreed when this service is assigned to a client. On by\ndefault; switch it off for services where catching up on backlog makes no sense."
          },
          "billingTiming": {
            "$ref": "#/components/schemas/BillingTiming"
          },
          "compoundPercentageFactors": {
            "type": "boolean",
            "description": "Whether percentage pricing factors compound (+20% and +10% is +32%) rather than\nadd (+30%). Fixed-amount factors are added afterwards either way."
          },
          "hasPreparerRole": {
            "type": "boolean",
            "description": "Whether clients on this service have a Preparer. When on, the Preparer is asked for when the\nservice is assigned to a client, and tasks and steps can be assigned to them."
          },
          "defaultPreparerUserCode": {
            "type": "string",
            "description": "The code of the user who is the default Preparer when the service is assigned to a client",
            "nullable": true
          },
          "hasReviewerRole": {
            "type": "boolean",
            "description": "Whether clients on this service have a Reviewer. When on, the Reviewer is asked for when the\nservice is assigned to a client, and tasks and steps can be assigned to them."
          },
          "defaultReviewerUserCode": {
            "type": "string",
            "description": "The code of the user who is the default Reviewer when the service is assigned to a client",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating an existing billable service"
      },
      "UpdateCalendarSubscriptionRequest": {
        "required": [
          "color",
          "name",
          "url"
        ],
        "type": "object",
        "properties": {
          "url": {
            "maxLength": 2048,
            "minLength": 1,
            "type": "string",
            "description": "The ICS feed URL — https:// or webcal://."
          },
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "Display name for the calendar."
          },
          "color": {
            "maxLength": 7,
            "minLength": 1,
            "pattern": "^#[0-9a-fA-F]{6}$",
            "type": "string",
            "description": "Hex display colour for events from this calendar (e.g. \"#3B82F6\")."
          },
          "isVisible": {
            "type": "boolean",
            "description": "Whether events from this calendar are shown on the task calendar."
          }
        },
        "additionalProperties": false,
        "description": "Full replacement of a calendar subscription's editable fields. A changed URL is re-validated\nby fetching it."
      },
      "UpdateCisManagerSettingsRequest": {
        "type": "object",
        "properties": {
          "cisPaymentsEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block a Collect CIS payments step emails the client with",
            "nullable": true
          },
          "cisReturnConfirmationEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block a Confirm CIS return step emails the contractor with",
            "nullable": true
          },
          "cisPaymentsReminderEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block a Remind client about CIS payments step emails the client with",
            "nullable": true
          },
          "cisPaymentsPayableEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block the client is emailed with when subcontractors on their CIS payments page are verified\nand they can now pay them",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update the practice's CIS Manager settings. A full replacement: a template left out is cleared."
      },
      "UpdateClientAgentAuthorisationRequest": {
        "required": [
          "authorisationType",
          "status"
        ],
        "type": "object",
        "properties": {
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          },
          "status": {
            "$ref": "#/components/schemas/AgentAuthorisationStatus"
          }
        },
        "additionalProperties": false
      },
      "UpdateClientBillableServiceNotesRequest": {
        "type": "object",
        "properties": {
          "notes": {
            "type": "string",
            "description": "The notes, as HTML (plain text is accepted and kept with its line breaks). Null or blank clears them.",
            "nullable": true
          },
          "showNotesOnCard": {
            "type": "boolean",
            "description": "Whether the notes show on the service's card on the client's Services tab"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for saving the practice's notes on a client's service"
      },
      "UpdateClientBillableServiceRequest": {
        "required": [
          "billableServiceCode",
          "billingFrequency",
          "startDate"
        ],
        "type": "object",
        "properties": {
          "billableServiceCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the billable service to assign to this client"
          },
          "billingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "price": {
            "type": "number",
            "description": "The base price for this client's service (before any adjustment).\nThe final price is: Price + (Price * PriceAdjustmentPercentage / 100) + PriceAdjustmentFixedAmount.\nRequired when OverridePricing = true; ignored when OverridePricing = false (price comes from BillableService).\nNegative values are allowed (e.g. discounts / credit lines on a proposal).",
            "format": "double",
            "nullable": true
          },
          "overridePricing": {
            "type": "boolean",
            "description": "Indicates whether to use a custom Price value instead of BillableService pricing\nIf true: Must provide Price value\nIf false: Price is loaded from BillableService, and the client-level adjustment is applied"
          },
          "priceAdjustmentPercentage": {
            "type": "number",
            "description": "Percentage contribution from selected Percentage-mode pricing factors (positive or negative). Use -10 for 10% discount, 20 for 20% markup. Defaults to 0.",
            "format": "double"
          },
          "priceAdjustmentFixedAmount": {
            "type": "number",
            "description": "Absolute currency contribution from selected FixedAmount-mode pricing factors (positive or negative). Defaults to 0.",
            "format": "double"
          },
          "startDate": {
            "type": "string",
            "description": "The start date for this service",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "The end date for this service (optional - null means ongoing)",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ServiceStatus"
          },
          "managedByUserCode": {
            "type": "string",
            "description": "The code of the user managing this service",
            "nullable": true
          },
          "preparerUserCode": {
            "type": "string",
            "description": "The code of the user who prepares the work. Ignored while the service has no Preparer role:\nan update then keeps the stored Preparer.",
            "nullable": true
          },
          "reviewerUserCode": {
            "type": "string",
            "description": "The code of the user who reviews the work. Ignored while the service has no Reviewer role:\nan update then keeps the stored Reviewer.",
            "nullable": true
          },
          "pricingAnswers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The pricing factor answers that determined the final price\nKey: Question, Value: Answer",
            "nullable": true
          },
          "pricingTierCode": {
            "type": "string",
            "description": "The code of the custom pricing tier to apply. Required when the BillableService uses CustomTiers and OverridePricing = false.",
            "nullable": true
          },
          "stageCode": {
            "type": "string",
            "description": "The code of the current workflow stage to set on this service (optional)",
            "nullable": true
          },
          "servicePackageCode": {
            "type": "string",
            "description": "The code of the service package this service was created from, if any.\nLinks the service to its originating package for display and pricing purposes.",
            "nullable": true
          },
          "overrideServicePackagePrice": {
            "type": "boolean",
            "description": "Whether the package-level price is agreed for this client rather than inherited from the\npackage: the package-level twin of SodiumHQ.DTOs.ClientBillableService.CreateClientBillableServiceRequest.OverridePricing. True, send the agreed figure\nin SodiumHQ.DTOs.ClientBillableService.CreateClientBillableServiceRequest.ServicePackagePrice on every member of the package. False, the price is\nstamped from the package as it stands (bug 2328), and an update that turns the flag off\nre-stamps from the package."
          },
          "servicePackagePrice": {
            "type": "number",
            "description": "The package-level price for a member of a package-priced package. Required when\nSodiumHQ.DTOs.ClientBillableService.CreateClientBillableServiceRequest.OverrideServicePackagePrice is true; ignored otherwise, where the price is\nstamped from the package.",
            "format": "double",
            "nullable": true
          },
          "servicePackageBillingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "setupFee": {
            "type": "number",
            "description": "The one-off setup fee for this client's service. Null means no setup fee.\nWhen OverrideSetupFee = false, pass the BillableService.SetupFee default (or null).\nWhen OverrideSetupFee = true, pass the custom fee (null/0 removes the fee for this client).",
            "format": "double",
            "nullable": true
          },
          "overrideSetupFee": {
            "type": "boolean",
            "description": "Indicates whether to use a custom SetupFee value instead of the BillableService default"
          },
          "autoInvoice": {
            "type": "boolean",
            "description": "Whether this service is on the billing schedule. On: occurrences are generated from the start\ndate, frequency and end date, and due ones become billing lines nightly. Off: the service is\nbilled outside Sodium."
          },
          "setupFeeBillingMoment": {
            "$ref": "#/components/schemas/SetupFeeBillingMoment"
          },
          "billingTiming": {
            "$ref": "#/components/schemas/BillingTiming"
          },
          "catchUp": {
            "$ref": "#/components/schemas/CatchUpFeeDto"
          },
          "overrideCatchUpFee": {
            "type": "boolean",
            "description": "Whether the catch-up fee was agreed for this client rather than worked out as the months times\nthe monthly-equivalent rate. Ignored (stored false) when there is no catch-up fee."
          },
          "unitQuantity": {
            "type": "number",
            "description": "The expected quantity per billing period for services with a non-Fixed pricing basis\n(e.g. 12 employees). Null means the volume is unknown. Ignored for Fixed services.",
            "format": "double",
            "nullable": true
          },
          "quantityVariesPerPeriod": {
            "type": "boolean",
            "description": "Whether the billed quantity is expected to change from period to period. When true (default),\ngenerated billing lines for this service are always created Pending so the quantity can be\nconfirmed before invoicing, regardless of the approval settings. Seeded from the\nBillableService default at assignment. Ignored for Fixed services."
          },
          "createOnboardingTasks": {
            "type": "boolean",
            "description": "Whether to create the service's onboarding tasks when it is added as Active, or an update moves\nit from Proposed to Active. Defaults to true. Set to false when back-filling a service the\nclient already has, so no tasks are created for work already done."
          },
          "notes": {
            "type": "string",
            "description": "The practice's own notes on this client's service, as HTML (plain text is accepted and kept\nwith its line breaks). Optional. Ignored on an update, which keeps the stored notes: change them\nwith the client service notes endpoint.",
            "nullable": true
          },
          "showNotesOnCard": {
            "type": "boolean",
            "description": "Whether the notes show on the service's card on the client's Services tab. Defaults to true.\nIgnored on an update, like SodiumHQ.DTOs.ClientBillableService.CreateClientBillableServiceRequest.Notes."
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating an existing client billable service assignment"
      },
      "UpdateClientBillableServiceStageRequest": {
        "type": "object",
        "properties": {
          "stageCode": {
            "type": "string",
            "description": "The code of the stage to move the client to. Null to clear the stage.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a client billable service stage (kanban drag-and-drop)"
      },
      "UpdateClientBillingLineItemRequest": {
        "required": [
          "description"
        ],
        "type": "object",
        "properties": {
          "clientBillableServiceCode": {
            "type": "string",
            "description": "The code of the client service this line attributes to, so money billed on account or as\na progress bill counts toward the job. Omitted (null), the existing link is kept; lines\npromoted from the billing schedule keep theirs regardless.",
            "nullable": true
          },
          "description": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "The invoice line description"
          },
          "quantity": {
            "type": "number",
            "description": "The quantity",
            "format": "double"
          },
          "unitPrice": {
            "type": "number",
            "description": "The unit price",
            "format": "double"
          },
          "vatRate": {
            "$ref": "#/components/schemas/VatRate"
          },
          "accountingCode": {
            "maxLength": 20,
            "type": "string",
            "description": "The accounting/nominal code (optional)",
            "nullable": true
          },
          "periodStart": {
            "type": "string",
            "description": "Start of the service period covered (optional)",
            "format": "date-time",
            "nullable": true
          },
          "periodEnd": {
            "type": "string",
            "description": "End of the service period covered (optional)",
            "format": "date-time",
            "nullable": true
          },
          "billingDate": {
            "type": "string",
            "description": "Target invoice date",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Request to update a billing line item. A line derived from time (billed time entries behind\nit) keeps its quantity and unit price: its amount is the sum of the entries' allocations, so\nit is undone by deleting it, not edited."
      },
      "UpdateClientBillingLineItemStatusRequest": {
        "required": [
          "status"
        ],
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ClientBillingLineItemStatus"
          }
        },
        "additionalProperties": false,
        "description": "Request to update the status of a billing line item"
      },
      "UpdateClientBillingScheduleItemRequest": {
        "required": [
          "billingDate"
        ],
        "type": "object",
        "properties": {
          "billingDate": {
            "type": "string",
            "description": "The date to bill the occurrence on",
            "format": "date"
          },
          "quantity": {
            "minimum": 0.01,
            "type": "number",
            "description": "The quantity to bill. Leave null to keep taking it from the rule.",
            "format": "double",
            "nullable": true
          },
          "unitPrice": {
            "type": "number",
            "description": "The unit price to bill at. Leave null to keep taking it from the rule.",
            "format": "double",
            "nullable": true
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "The invoice line description. Leave null to keep deriving it from the rule's template at promotion.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to edit one scheduled occurrence: its billing date, amount and description. The date is\nalways pinned and marks the item edited, so a later reconcile leaves it alone. A null quantity,\nprice or description clears any override and goes back to following the service's billing rule.\nOnly a Scheduled item can be edited."
      },
      "UpdateClientBillingSettingsRequest": {
        "type": "object",
        "properties": {
          "clientBillingEnabled": {
            "type": "boolean",
            "description": "Whether recurring client billing features are enabled for this tenant"
          },
          "defaultInvoiceDayOfMonth": {
            "type": "integer",
            "description": "Default day of month (1-28) for automatic invoicing on new clients. Null means no default.",
            "format": "int32",
            "nullable": true
          },
          "defaultInvoicePaymentTermDays": {
            "type": "integer",
            "description": "Default payment terms in days for generated invoices on new clients (e.g. 30)",
            "format": "int32",
            "nullable": true
          },
          "defaultLineItemApprovalRequired": {
            "type": "boolean",
            "description": "Default for whether generated line items require manual approval before invoicing on new clients"
          },
          "defaultAccountingCode": {
            "type": "string",
            "description": "Default accounting/nominal code for new billable services and manual line items",
            "nullable": true
          },
          "syncClientDetailsToAccountingConnection": {
            "type": "boolean",
            "description": "Whether client detail changes (name, email, phone, billing address) are pushed to the\ntenant's connected accounting platform. Sodium remains the master record."
          },
          "defaultSetupFeeBillingMoment": {
            "$ref": "#/components/schemas/SetupFeeBillingMoment"
          },
          "defaultCatchUpBillingMoment": {
            "$ref": "#/components/schemas/SetupFeeBillingMoment"
          },
          "createInvoicesAsDrafts": {
            "type": "boolean",
            "description": "Whether invoices Sodium raises in the accounting platform are left as drafts for review there\nrather than approved on creation. Only platforms with a draft state honour it; see the\nplatform's supportsDraftInvoices flag."
          },
          "emailInvoicesToClients": {
            "type": "boolean",
            "description": "Whether invoices Sodium raises are then emailed to the client by the accounting platform; see\nthe platform's supportsSendInvoice flag. Rejected together with\nSodiumHQ.DTOs.Invoicing.UpdateClientBillingSettingsRequest.CreateInvoicesAsDrafts — a draft cannot be emailed."
          }
        },
        "additionalProperties": false,
        "description": "Request to update client billing settings for the tenant"
      },
      "UpdateClientContactRequest": {
        "required": [
          "types"
        ],
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "description": "The role of the contact within this client relationship",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "The type of contact relationship"
          },
          "contact": {
            "$ref": "#/components/schemas/ContactDto"
          },
          "resignedDate": {
            "type": "string",
            "description": "Date the contact resigned their officer role for this client. Usually populated by the\nCompanies House officer stream; user-editable so it can also be set manually (or cleared).",
            "format": "date",
            "nullable": true
          },
          "ceasedDate": {
            "type": "string",
            "description": "Date the contact ceased being a Person with Significant Control for this client. Usually\npopulated by the Companies House PSC stream; user-editable so it can also be set manually.",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a client-contact relationship"
      },
      "UpdateClientDataFieldDto": {
        "type": "object",
        "properties": {
          "fieldType": {
            "$ref": "#/components/schemas/DataFormQuestionType"
          },
          "clientField": {
            "$ref": "#/components/schemas/ClientCsvTargetField"
          },
          "customFieldDefinitionCode": {
            "type": "string",
            "description": "The custom field definition code when FieldType is CustomField.",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Display order within the step.",
            "format": "int32"
          },
          "instructions": {
            "type": "string",
            "description": "Optional instructions or description for this field (supports template tokens).",
            "nullable": true
          },
          "isRequired": {
            "type": "boolean",
            "description": "Whether this field must be filled before the step can be completed."
          },
          "defaultValue": {
            "type": "string",
            "description": "Optional default value to pre-fill the field with.\nWhen all fields have default values and the step is set to AutoExecute,\nthe step can run automatically without user input.",
            "nullable": true
          },
          "clearValue": {
            "type": "boolean",
            "description": "Clears the field's existing value when the step runs, instead of writing a default.\nTakes precedence over DefaultValue. Lets an auto-executing step blank a field, which an\nempty DefaultValue can't express (that means \"leave this field alone\")."
          }
        },
        "additionalProperties": false,
        "description": "A single field within an UpdateClientData step configuration."
      },
      "UpdateClientDataStepConfigDto": {
        "type": "object",
        "properties": {
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UpdateClientDataFieldDto"
            },
            "description": "The fields to present for updating, ordered by SortOrder.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Configuration for UpdateClientData workflow steps.\nDefines which client/custom fields the user should review and update."
      },
      "UpdateClientDocumentRequest": {
        "type": "object",
        "properties": {
          "documentCategoryCode": {
            "type": "string",
            "description": "The document category code. Optional — if omitted, the document will have no category assigned.",
            "nullable": true
          },
          "title": {
            "maxLength": 500,
            "type": "string",
            "description": "The title of the document",
            "nullable": true
          },
          "summary": {
            "type": "string",
            "description": "A brief summary or description of the document",
            "nullable": true
          },
          "date": {
            "type": "string",
            "description": "The date the document is dated (not the creation date)",
            "format": "date"
          },
          "visibleInClientPortal": {
            "type": "boolean",
            "description": "Whether this document is visible to the client in the portal. Defaults to true.\nDoes not affect visibility in external storage providers — only controls portal access."
          },
          "portalFolderPath": {
            "type": "string",
            "description": "Folder path controlling where this document appears in the client portal.\nFormat: \"/\" separated folder names, e.g. \"Tax Returns/2026\".\nNull or empty for root-level. Only applies to portal display — does not move the physical file.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpdateClientEmailRuleRequest": {
        "required": [
          "value"
        ],
        "type": "object",
        "properties": {
          "value": {
            "maxLength": 255,
            "minLength": 0,
            "type": "string",
            "description": "The email address, domain, or message ID to match.\nEmail addresses (contain '@') match that specific participant.\nDomains (no '@', not a GUID) match all emails from that domain.\nMessage IDs (valid GUID) pin a specific email to this client."
          }
        },
        "additionalProperties": false,
        "description": "Request to update an existing email matching rule.\nProvide an email address (e.g. \"john@acme.com\") to match that specific address,\na domain (e.g. \"acme.com\") to match all emails from that domain,\nor a message ID (GUID) to pin a specific email to this client."
      },
      "UpdateClientLinkRequest": {
        "required": [
          "linkType",
          "url"
        ],
        "type": "object",
        "properties": {
          "url": {
            "minLength": 1,
            "type": "string",
            "description": "The URL of the link",
            "format": "uri"
          },
          "linkType": {
            "$ref": "#/components/schemas/LinkType"
          },
          "displayName": {
            "maxLength": 200,
            "type": "string",
            "description": "Optional display name shown as anchor text instead of the URL",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a client link"
      },
      "UpdateClientNoteRequest": {
        "required": [
          "date",
          "text"
        ],
        "type": "object",
        "properties": {
          "text": {
            "minLength": 1,
            "type": "string",
            "description": "The text content of the note"
          },
          "date": {
            "type": "string",
            "description": "The date/time the note was created",
            "format": "date-time"
          },
          "noteFromUserCode": {
            "type": "string",
            "description": "The code of the user who authored this note. Defaults to the authenticated user if not provided.",
            "nullable": true
          },
          "pinnedLevel": {
            "type": "integer",
            "description": "The pinned level: 0 not pinned, 1 top of the notes section, 2 top of the client or task page, 3 the dashboard",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a client note"
      },
      "UpdateClientPipelineDealRequest": {
        "type": "object",
        "properties": {
          "value": {
            "maximum": 99999999.99,
            "minimum": 0,
            "type": "number",
            "description": "What the deal is worth if it closes. Null to clear.",
            "format": "double",
            "nullable": true
          },
          "likelihood": {
            "maximum": 100,
            "minimum": 0,
            "type": "integer",
            "description": "How likely the deal is to close, as a percentage 0-100. Null to clear.",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for setting a client pipeline card's deal value and likelihood. Both are optional;\nnull clears the field."
      },
      "UpdateClientPipelineRequest": {
        "required": [
          "pipelineCode",
          "startDate"
        ],
        "type": "object",
        "properties": {
          "pipelineCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the pipeline to place the client on"
          },
          "stageCode": {
            "type": "string",
            "description": "The code of the initial stage (optional — null means no stage yet)",
            "nullable": true
          },
          "managedByUserCode": {
            "type": "string",
            "description": "The code of the user managing this card (optional)",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "description": "The date the client entered the pipeline",
            "format": "date-time"
          },
          "value": {
            "maximum": 99999999.99,
            "minimum": 0,
            "type": "number",
            "description": "What the deal is worth if it closes (optional)",
            "format": "double",
            "nullable": true
          },
          "likelihood": {
            "maximum": 100,
            "minimum": 0,
            "type": "integer",
            "description": "How likely the deal is to close, as a percentage 0-100 (optional)",
            "format": "int32",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "The date the client left the pipeline (optional)",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a client's pipeline card (full replacement)"
      },
      "UpdateClientPipelineStageRequest": {
        "type": "object",
        "properties": {
          "stageCode": {
            "type": "string",
            "description": "The code of the stage to move the client to. Null to clear the stage.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a client pipeline card's stage (kanban drag-and-drop)"
      },
      "UpdateClientPortalSettingsRequest": {
        "type": "object",
        "properties": {
          "portalTitle": {
            "type": "string",
            "description": "The title displayed on the client portal",
            "nullable": true
          },
          "designThemeCode": {
            "type": "string",
            "description": "Code of the design theme to apply to the client portal",
            "nullable": true
          },
          "iconImageAssetCode": {
            "type": "string",
            "description": "Code of the image asset to use as the portal icon/favicon",
            "nullable": true
          },
          "showInvoices": {
            "type": "boolean",
            "description": "Whether portal users can view their invoices"
          },
          "showServices": {
            "type": "boolean",
            "description": "Whether portal users can view the services set up for them in Sodium"
          },
          "invitationEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use for portal invitation emails",
            "nullable": true
          },
          "useIntroPageContentBlock": {
            "type": "boolean",
            "description": "When true, the intro page uses the content block. When false, it uses IntroPageText."
          },
          "introPageContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use for the intro page",
            "nullable": true
          },
          "introPageText": {
            "type": "string",
            "description": "Raw HTML content for the intro page (used when UseIntroPageContentBlock is false)",
            "nullable": true
          },
          "notifyManagerOnClientDocumentUpload": {
            "type": "boolean",
            "description": "Whether to send an email notification to the client's manager when a document is uploaded via the portal"
          }
        },
        "additionalProperties": false,
        "description": "Request to update client portal settings for the tenant"
      },
      "UpdateClientRequest": {
        "required": [
          "name",
          "type"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the client"
          },
          "type": {
            "$ref": "#/components/schemas/ClientType"
          },
          "internalReference": {
            "type": "string",
            "description": "Optional internal reference number/code for the client",
            "nullable": true
          },
          "managerCode": {
            "type": "string",
            "description": "Code of the user who will manage this client.\nThe user must exist and have access to the tenant.",
            "nullable": true
          },
          "partnerCode": {
            "type": "string",
            "description": "Code of the user who will be the partner for this client.\nThe user must exist and have access to the tenant.",
            "nullable": true
          },
          "associateCode": {
            "type": "string",
            "description": "Code of the user who will be the associate for this client.\nThe user must exist and have access to the tenant.",
            "nullable": true
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of teams to assign to this client",
            "nullable": true
          },
          "isAccessRestricted": {
            "type": "boolean",
            "description": "When true, only the people in AccessUserCodes may see this client, on top of the usual visibility rule.\nNull leaves the client's setting as it is. Switching it on adds the saving user to the list.",
            "nullable": true
          },
          "accessUserCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the users who may see this client while its access is restricted. Null leaves the list as it is.\nThe saving user must be on it while access is restricted.",
            "nullable": true
          },
          "revenueRangeCode": {
            "type": "string",
            "description": "The revenue range code for this client",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ClientStatus"
          },
          "accountingCustomerCode": {
            "type": "string",
            "description": "The customer code/ID from the connected accounting platform",
            "nullable": true
          },
          "directDebitMandateId": {
            "type": "string",
            "description": "The mandate ID from the connected direct debit platform",
            "nullable": true
          },
          "amlClientId": {
            "type": "string",
            "description": "The client/account ID from the connected AML platform",
            "nullable": true
          },
          "amlClientName": {
            "type": "string",
            "description": "The display name of the client in the connected AML platform",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The email address for the client",
            "nullable": true
          },
          "alternativeEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional email addresses for the client. Email remains the primary address.\nBlank entries and duplicates of the primary address are discarded.",
            "nullable": true
          },
          "telephone": {
            "type": "string",
            "description": "The telephone number for the client",
            "nullable": true
          },
          "alternativePhoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional phone numbers for the client. Telephone remains the primary number.\nBlank entries and duplicates of the primary number are discarded.",
            "nullable": true
          },
          "contactPreferences": {
            "$ref": "#/components/schemas/ContactPreferencesDto"
          },
          "invoiceDayOfMonth": {
            "type": "integer",
            "description": "Day of month (1-28) for automatic invoicing. Null disables auto-invoicing.",
            "format": "int32",
            "nullable": true
          },
          "invoicePaymentTermDays": {
            "type": "integer",
            "description": "Payment terms in days for generated invoices",
            "format": "int32",
            "nullable": true
          },
          "lineItemApprovalRequired": {
            "type": "boolean",
            "description": "Null = use tenant default. True = require manual approval. False = auto-approve.",
            "nullable": true
          },
          "vatTreatment": {
            "$ref": "#/components/schemas/ClientVatTreatment"
          },
          "pclSent": {
            "type": "boolean",
            "description": "Indicates whether a Professional Clearance Letter has been sent for this client"
          },
          "snoozeChasesUntil": {
            "type": "string",
            "description": "Suppresses automated chase emails for this client until this date (chasing resumes on the date itself).\nNull = chases are not snoozed.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating an existing client"
      },
      "UpdateClientRequestSettingsRequest": {
        "type": "object",
        "properties": {
          "documentApprovalEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template for document approval request emails",
            "nullable": true
          },
          "documentRequestOpenedEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template when a document request is opened",
            "nullable": true
          },
          "documentRequestRejectedEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template when a document request submission is rejected",
            "nullable": true
          },
          "documentRequestSubmittedEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template when a document request submission is received",
            "nullable": true
          },
          "clientConfirmationEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template for client confirmation workflow step emails",
            "nullable": true
          },
          "clientChaseEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template for client chase emails",
            "nullable": true
          },
          "dataFormSubmissionEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template for form submission emails",
            "nullable": true
          },
          "chaseDocumentRequestFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase open document requests",
            "format": "int32",
            "nullable": true
          },
          "chaseDocumentApprovalFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase pending document approvals",
            "format": "int32",
            "nullable": true
          },
          "chaseClientConfirmationFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase pending client confirmations",
            "format": "int32",
            "nullable": true
          },
          "chaseDataFormSubmissionFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase pending data form submissions",
            "format": "int32",
            "nullable": true
          },
          "hmrcAuthorisationRequestEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template for HMRC authorisation request emails",
            "nullable": true
          },
          "chaseHmrcAuthorisationFrequencyDays": {
            "type": "integer",
            "description": "How often (in days) to chase pending HMRC agent authorisation requests",
            "format": "int32",
            "nullable": true
          },
          "isChaseTextEnabled": {
            "type": "boolean",
            "description": "Whether each chase also texts each recipient who is one of the client's contacts with a mobile, one text per\nrecipient per client per chase; it texts only while the practice's messaging is Active"
          },
          "documentNotificationEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template for document notification emails",
            "nullable": true
          },
          "authCodeEntryEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the email body template for the HMRC code entry email",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update client request and chasing settings for the tenant"
      },
      "UpdateClientServiceBudgetRequest": {
        "type": "object",
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/ClientBudgetMode"
          },
          "adjustPercent": {
            "maximum": 500,
            "minimum": -100,
            "type": "number",
            "description": "The percentage on every line still following the standard; required under StandardAdjusted",
            "format": "double",
            "nullable": true
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetLineOverrideRequest"
            },
            "description": "The client's own figures; lines left out follow the standard",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Sets how one client's hours (or, through the fee route, its fee) relate to the standard, and its\nown figures line by line."
      },
      "UpdateClientSettingsRequest": {
        "type": "object",
        "properties": {
          "clientManager_Enabled": {
            "type": "boolean",
            "description": "Whether the client manager field is enabled for clients"
          },
          "clientManager_Label": {
            "maxLength": 50,
            "type": "string",
            "description": "Optional custom label for the client manager field. Null means use the default.",
            "nullable": true
          },
          "clientManager_Required": {
            "type": "boolean",
            "description": "Whether a client must have a client manager. Enforced on create and update only; existing clients are not backfilled.\nIgnored while ClientManager_Enabled is off."
          },
          "partner_Enabled": {
            "type": "boolean",
            "description": "Whether the partner field is enabled for clients"
          },
          "partner_Label": {
            "maxLength": 50,
            "type": "string",
            "description": "Optional custom label for the partner field. Null means use the default.",
            "nullable": true
          },
          "partner_Required": {
            "type": "boolean",
            "description": "Whether a client must have a partner. Enforced on create and update only; existing clients are not backfilled.\nIgnored while Partner_Enabled is off."
          },
          "associate_Enabled": {
            "type": "boolean",
            "description": "Whether the associate field is enabled for clients"
          },
          "associate_Label": {
            "maxLength": 50,
            "type": "string",
            "description": "Optional custom label for the associate field. Null means use the default.",
            "nullable": true
          },
          "associate_Required": {
            "type": "boolean",
            "description": "Whether a client must have a associate. Enforced on create and update only; existing clients are not backfilled.\nIgnored while Associate_Enabled is off."
          },
          "internalReference_Enabled": {
            "type": "boolean",
            "description": "Whether the internal reference field is enabled for clients"
          },
          "internalReference_ForceUnique": {
            "type": "boolean",
            "description": "Whether to force internal references to be unique across all clients"
          },
          "internalReference_AutoGenerate": {
            "type": "boolean",
            "description": "Whether to auto-generate the internal reference from the client code on creation"
          },
          "externalLinks_Enabled": {
            "type": "boolean",
            "description": "Whether external links are enabled for clients"
          },
          "companiesHouse_Enabled": {
            "type": "boolean",
            "description": "Whether the practice uses Companies House at all. Off disables every Companies House feature.\nTurn off for practices outside England and Wales."
          },
          "companiesHouseSync_Enabled": {
            "type": "boolean",
            "description": "Whether Companies House auto-sync is enabled for this tenant. When off, the\nCompanies House worker does not queue stream events for any of this tenant's clients.\nIgnored when SodiumHQ.DTOs.Client.UpdateClientSettingsRequest.CompaniesHouse_Enabled is off."
          },
          "agentAuthorisations_Enabled": {
            "type": "boolean",
            "description": "Whether the practice uses HMRC agent authorisations at all. Off hides the agent authorisations\nsection on clients, the authorisation types on services, and the HMRC Agent settings page,\nand stops authorisation chase emails."
          },
          "team_Enabled": {
            "type": "boolean",
            "description": "Whether the team field is enabled for clients"
          },
          "clientLogos_Enabled": {
            "type": "boolean",
            "description": "Whether client logos are shown. Off, no client is shown with a logo or badge anywhere."
          }
        },
        "additionalProperties": false,
        "description": "Request to update client settings for the tenant"
      },
      "UpdateClientThirdPartyMappingRequest": {
        "type": "object",
        "properties": {
          "accountingCustomerCode": {
            "type": "string",
            "description": "The customer code/ID from the connected accounting platform",
            "nullable": true
          },
          "directDebitMandateId": {
            "type": "string",
            "description": "The mandate ID from the connected direct debit platform",
            "nullable": true
          },
          "amlClientId": {
            "type": "string",
            "description": "The client/account ID from the connected AML platform",
            "nullable": true
          },
          "amlClientName": {
            "type": "string",
            "description": "The display name of the client in the connected AML platform",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a client's third-party platform mappings.\nImplements RFC 7396 JSON Merge Patch semantics: only fields present in the\nJSON body are updated; absent fields are left unchanged in the database."
      },
      "UpdateContactRequest": {
        "type": "object",
        "properties": {
          "title": {
            "maxLength": 20,
            "type": "string",
            "description": "The contact's title (e.g., Mr, Mrs, Ms, Dr)",
            "nullable": true
          },
          "firstName": {
            "maxLength": 100,
            "type": "string",
            "description": "The contact's first name",
            "nullable": true
          },
          "middleName": {
            "maxLength": 100,
            "type": "string",
            "description": "The contact's middle name",
            "nullable": true
          },
          "lastName": {
            "maxLength": 100,
            "type": "string",
            "description": "The contact's last name",
            "nullable": true
          },
          "preferredName": {
            "maxLength": 100,
            "type": "string",
            "description": "The name the contact goes by, when different from their first name (e.g. Matt for Matthias)",
            "nullable": true
          },
          "email": {
            "maxLength": 200,
            "type": "string",
            "description": "The contact's email address",
            "nullable": true
          },
          "alternativeEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional email addresses the contact also uses. Email remains the primary\naddress and is the default for outgoing communication. Blank entries and\nduplicates of the primary address are discarded.",
            "nullable": true
          },
          "phone": {
            "maxLength": 50,
            "type": "string",
            "description": "The contact's landline phone number",
            "nullable": true
          },
          "mobile": {
            "maxLength": 50,
            "type": "string",
            "description": "The contact's mobile phone number",
            "nullable": true
          },
          "alternativePhoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional phone numbers the contact also uses. Phone and Mobile remain the\nprimary numbers. Blank entries and duplicates of the primary numbers are discarded.",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "description": "The contact's date of birth",
            "format": "date",
            "nullable": true
          },
          "utr": {
            "type": "string",
            "description": "The contact's Unique Taxpayer Reference (Self Assessment UTR).\nUsed for individuals' personal tax affairs.",
            "nullable": true
          },
          "niNumber": {
            "type": "string",
            "description": "The contact's National Insurance Number.",
            "nullable": true
          },
          "cgtReference": {
            "maxLength": 20,
            "type": "string",
            "description": "The contact's Capital Gains Tax on UK property account number, issued by HMRC when they\nfirst report a property disposal.",
            "nullable": true
          },
          "personalCode": {
            "maxLength": 50,
            "type": "string",
            "description": "The contact's Companies House person ID code, used to uniquely identify\nan individual within the Companies House system.",
            "nullable": true
          },
          "address": {
            "type": "string",
            "description": "The contact's address. Only used when the client type is Individual.",
            "nullable": true
          },
          "nationality": {
            "$ref": "#/components/schemas/Nationality"
          },
          "maritalStatus": {
            "$ref": "#/components/schemas/MaritalStatus"
          },
          "isDeceased": {
            "type": "boolean",
            "description": "Whether this contact is deceased"
          },
          "deceasedDate": {
            "type": "string",
            "description": "The date the contact was deceased, if known",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for updating a contact"
      },
      "UpdateContentBlockRequest": {
        "required": [
          "category",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "Display name for the content block"
          },
          "bodyHtml": {
            "type": "string",
            "description": "HTML content of the block with Liquid syntax support",
            "nullable": true
          },
          "description": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "Optional description explaining the block's purpose and where it should be used",
            "nullable": true
          },
          "category": {
            "$ref": "#/components/schemas/ContentBlockCategory"
          },
          "subjectLine": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "Optional subject line for email content blocks (only relevant when Category is EmailParts).\nSupports merge field syntax (e.g., {{ Client.Name }}).",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update an existing content block"
      },
      "UpdateCsvMappingRequest": {
        "required": [
          "columnMappings",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "Human-readable display name for this mapping.\nChoose a descriptive name that identifies the CSV format (e.g., 'IRIS Export', 'Xero Contacts').\nRequired.",
            "example": "IRIS Client Export"
          },
          "columnMappings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CsvColumnMappingDto"
            },
            "description": "The column mappings that define how CSV headers map to client fields.\nEach mapping specifies a CSV header and the corresponding target field.\nRequired - must include at least one mapping."
          },
          "matchField": {
            "$ref": "#/components/schemas/CsvImportMatchField"
          }
        },
        "additionalProperties": false,
        "description": "Request to update an existing CSV mapping."
      },
      "UpdateCustomFieldDefinitionRequest": {
        "required": [
          "customFieldGroupCode"
        ],
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "nullable": true
          },
          "dataType": {
            "$ref": "#/components/schemas/CustomFieldDataType"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "maxLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "lines": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "displayWidth": {
            "$ref": "#/components/schemas/FieldDisplayWidth"
          },
          "booleanDisplayMode": {
            "$ref": "#/components/schemas/BooleanDisplayMode"
          },
          "isFullRow": {
            "type": "boolean",
            "description": "Whether the field takes a whole row of its card on the record, rather than one column of it.\nDisplayWidth then applies within that row. Only for types whose metadata has HasFullRow."
          },
          "numberDecimalPlaces": {
            "maximum": 2,
            "minimum": 0,
            "type": "integer",
            "description": "Number fields only: decimal places the value renders with in templates (0 to 2). Null keeps the decimals as entered.",
            "format": "int32",
            "nullable": true
          },
          "numberThousandsSeparator": {
            "type": "boolean",
            "description": "Number fields only: whether the value renders in templates with a thousands separator."
          },
          "numberCurrencySymbol": {
            "type": "boolean",
            "description": "Number fields only: whether the value renders in templates with the practice currency symbol."
          },
          "clientTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "The types of clients this custom field is applicable to.\nAn empty list means the field is applicable to all client types.",
            "nullable": true
          },
          "billableServiceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the services a client must hold for this custom field to apply to them.\nAn empty list means the field applies regardless of the client's services.",
            "nullable": true
          },
          "isRequired": {
            "type": "boolean",
            "description": "Whether a value must be held for this field on every client the field applies to.\nA required field restricted by client type or by service is required only on the clients\nit applies to."
          },
          "customFieldGroupCode": {
            "minLength": 1,
            "type": "string"
          },
          "isArchived": {
            "type": "boolean"
          },
          "sortOrder": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "UpdateCustomFieldGroupRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string"
          },
          "parentCustomFieldGroupCode": {
            "type": "string",
            "nullable": true
          },
          "condition": {
            "$ref": "#/components/schemas/ConditionDto"
          },
          "sortOrder": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "UpdateCustomTokenRequest": {
        "required": [
          "name",
          "tokenIdentifier"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 120,
            "minLength": 1,
            "type": "string",
            "description": "Human-readable display name for the token (e.g. \"Company Secretary\")"
          },
          "tokenIdentifier": {
            "maxLength": 120,
            "minLength": 1,
            "type": "string",
            "description": "The token identifier used in templates (e.g. \"CompanySecretary\" for {{ Custom.CompanySecretary }}).\nMust be alphanumeric with underscores only. Unique per tenant."
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional prompt text shown when filling in the token value",
            "nullable": true
          },
          "defaultValue": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional default value pre-populated in the token form",
            "nullable": true
          },
          "displayWidth": {
            "type": "string",
            "description": "Preset display width for the input. Null defaults to Full.",
            "nullable": true
          },
          "lines": {
            "type": "integer",
            "description": "Number of visible text lines. Null renders a single-line input, 2+ renders a textarea.",
            "format": "int32",
            "nullable": true
          },
          "isRichText": {
            "type": "boolean",
            "description": "When true and Lines >= 2, the input renders as a rich text editor instead of a plain textarea."
          },
          "isNumber": {
            "type": "boolean",
            "description": "When true the value is a number: the input takes a number and the token renders with the number format."
          },
          "numberDecimalPlaces": {
            "maximum": 2,
            "minimum": 0,
            "type": "integer",
            "description": "Number tokens only: decimal places the value renders with (0 to 2). Null keeps the decimals as entered.",
            "format": "int32",
            "nullable": true
          },
          "numberThousandsSeparator": {
            "type": "boolean",
            "description": "Number tokens only: whether the value renders with a thousands separator."
          },
          "numberCurrencySymbol": {
            "type": "boolean",
            "description": "Number tokens only: whether the value renders with the practice currency symbol."
          }
        },
        "additionalProperties": false,
        "description": "DTO for updating a custom token"
      },
      "UpdateDashboardLinkRequest": {
        "required": [
          "url"
        ],
        "type": "object",
        "properties": {
          "url": {
            "maxLength": 2000,
            "minLength": 1,
            "type": "string",
            "description": "Where the link goes. https:// is assumed when no scheme is given; only http and https are accepted."
          },
          "title": {
            "maxLength": 200,
            "type": "string",
            "description": "What to call the link. Null or blank removes the title, so the URL is shown.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for changing a link on the dashboard"
      },
      "UpdateDataFormCategoryRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The display name of the form category",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for updating a form category"
      },
      "UpdateDataFormRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "introduction": {
            "type": "string",
            "nullable": true
          },
          "dataFormCategoryCode": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/DataFormStatus"
          },
          "defaultMessage": {
            "type": "string",
            "nullable": true
          },
          "exportDocumentTemplateCode": {
            "type": "string",
            "description": "Code of the Form Answers template to export the form's answers with: one of this form's own. Null for the\nBasic layout. A save without it puts the form back on Basic.",
            "nullable": true
          },
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataFormSectionDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for updating a form (whole-form save including sections and questions)"
      },
      "UpdateDesignThemeRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name for the theme",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether this should be the default theme for the tenant"
          },
          "heading1": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "heading2": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "heading3": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "body": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "tableHeader": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "tableCell": {
            "$ref": "#/components/schemas/FontSettingsDto"
          },
          "logoUrl": {
            "type": "string",
            "description": "URL to the company logo image",
            "nullable": true
          },
          "primaryColor": {
            "type": "string",
            "description": "Primary brand color in hex format (e.g., \"#000000\")",
            "nullable": true
          },
          "secondaryColor": {
            "type": "string",
            "description": "Secondary brand color in hex format",
            "nullable": true
          },
          "accentColor": {
            "type": "string",
            "description": "Accent color in hex format",
            "nullable": true
          },
          "backgroundColor": {
            "type": "string",
            "description": "Optional page background color in hex format (e.g., \"#FFFFFF\"). Null for transparent/default.",
            "nullable": true
          },
          "linkColor": {
            "type": "string",
            "description": "Optional link color in hex format (e.g., \"#1E88E5\"). Null for default.",
            "nullable": true
          },
          "linkHoverColor": {
            "type": "string",
            "description": "Optional link hover color in hex format (e.g., \"#0D47A1\"). Null for default.",
            "nullable": true
          },
          "primaryButton": {
            "$ref": "#/components/schemas/ButtonStyleDto"
          },
          "secondaryButton": {
            "$ref": "#/components/schemas/ButtonStyleDto"
          },
          "navBackgroundColor": {
            "type": "string",
            "description": "Navigation background color for the client portal (e.g., \"#1e293b\")",
            "nullable": true
          },
          "navTextColor": {
            "type": "string",
            "description": "Navigation text color for the client portal",
            "nullable": true
          },
          "navActiveBackgroundColor": {
            "type": "string",
            "description": "Active navigation item highlight color (supports rgba, e.g., \"rgba(255,255,255,0.15)\")",
            "nullable": true
          },
          "navActiveTextColor": {
            "type": "string",
            "description": "Active navigation item text color",
            "nullable": true
          },
          "cardBackgroundColor": {
            "type": "string",
            "description": "Card/panel background color in the content area",
            "nullable": true
          },
          "borderRadius": {
            "type": "integer",
            "description": "Global corner radius in pixels for cards, buttons, and inputs",
            "format": "int32",
            "nullable": true
          },
          "navFontSize": {
            "type": "number",
            "description": "Font size in points for the client portal navigation bar. Null falls back to body font size.",
            "format": "float",
            "nullable": true
          },
          "faviconUrl": {
            "type": "string",
            "description": "URL to a tenant-specific favicon for the client portal",
            "nullable": true
          },
          "pageMargins": {
            "$ref": "#/components/schemas/MarginsDto"
          },
          "customCSS": {
            "type": "string",
            "description": "Additional custom CSS rules to append to the generated theme CSS",
            "nullable": true
          },
          "headerTextContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use for document headers.\nPDF only: repeats at the top of each page. When set, PageMarginTop is ignored.",
            "nullable": true
          },
          "headerPageSelection": {
            "$ref": "#/components/schemas/PageSelection"
          },
          "footerContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use for document footers.\nPDF only: repeats at the bottom of each page.",
            "nullable": true
          },
          "footerPageSelection": {
            "$ref": "#/components/schemas/PageSelection"
          },
          "pageNumberDisplay": {
            "$ref": "#/components/schemas/PageSelection"
          }
        },
        "additionalProperties": false,
        "description": "Request to update an existing design theme"
      },
      "UpdateDirectDebitSettingsRequest": {
        "type": "object",
        "properties": {
          "requestEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to include in the direct debit request email body",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update direct debit settings for the tenant"
      },
      "UpdateDocumentCategoryRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The display name of the document category",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying document categories",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "DTO for updating a document category"
      },
      "UpdateDocumentFilingSettingsRequest": {
        "type": "object",
        "properties": {
          "clientFolder_Name": {
            "maxLength": 400,
            "type": "string",
            "description": "The name of the folder made for each client under the base folder, when Sodium creates client\nfolders. A \"/\" makes a folder inside a folder. Only folders made from now on use it.",
            "nullable": true
          },
          "documentRequests_StoragePath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for files uploaded to a document request. Empty for the client's folder itself.",
            "nullable": true
          },
          "documentRequests_PortalPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Client portal folder for files uploaded to a document request. Empty for the portal root. Used when the practice publishes a request's files without choosing a folder.",
            "nullable": true
          },
          "documentRequests_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether files uploaded to a document request appear in the portal in the same folder as in storage, instead of DocumentRequests_PortalPath"
          },
          "generatedDocuments_StoragePath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for documents created from a template, by staff or a workflow step. Empty for the client's folder itself.",
            "nullable": true
          },
          "generatedDocuments_PortalPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Client portal folder for documents created from a template, by staff or a workflow step. Empty for the portal root. Used unless a folder was chosen for the document.",
            "nullable": true
          },
          "generatedDocuments_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether documents created from a template, by staff or a workflow step appear in the portal in the same folder as in storage, instead of GeneratedDocuments_PortalPath"
          },
          "formExports_StoragePath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for form answers saved as a PDF. Empty for the client's folder itself.",
            "nullable": true
          },
          "formExports_PortalPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Client portal folder for form answers saved as a PDF. Empty for the portal root. Used unless a folder was chosen for the document.",
            "nullable": true
          },
          "formExports_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether form answers saved as a PDF appear in the portal in the same folder as in storage, instead of FormExports_PortalPath"
          },
          "formUploads_StoragePath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for files clients upload in a form. Empty for the client's folder itself.",
            "nullable": true
          },
          "formUploads_PortalPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Client portal folder for files clients upload in a form. Empty for the portal root.",
            "nullable": true
          },
          "formUploads_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether files clients upload in a form appear in the portal in the same folder as in storage, instead of FormUploads_PortalPath"
          },
          "proposals_StoragePath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for the signed proposal saved when an engagement is accepted. Empty for the client's folder itself.",
            "nullable": true
          },
          "proposals_PortalPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Client portal folder for the signed proposal saved when an engagement is accepted. Empty for the portal root.",
            "nullable": true
          },
          "proposals_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether the signed proposal saved when an engagement is accepted appear in the portal in the same folder as in storage, instead of Proposals_PortalPath"
          },
          "engagementLetters_StoragePath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for the signed letter of engagement. Empty for the client's folder itself.",
            "nullable": true
          },
          "engagementLetters_PortalPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Client portal folder for the signed letter of engagement. Empty for the portal root.",
            "nullable": true
          },
          "engagementLetters_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether the signed letter of engagement appear in the portal in the same folder as in storage, instead of EngagementLetters_PortalPath"
          },
          "portalUploads_StoragePath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for files clients upload on the portal's Documents page. Empty for the client's folder itself.",
            "nullable": true
          },
          "portalUploads_PortalPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Client portal folder for files clients upload on the portal's Documents page. Empty for the portal root.",
            "nullable": true
          },
          "portalUploads_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether files clients upload on the portal's Documents page appear in the portal in the same folder as in storage, instead of PortalUploads_PortalPath"
          },
          "savedAttachments_StoragePath": {
            "maxLength": 400,
            "type": "string",
            "description": "Subfolder of the client's storage folder for email, WhatsApp and text attachments saved to the client. Empty for the client's folder itself.",
            "nullable": true
          },
          "savedAttachments_PortalPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Client portal folder for email, WhatsApp and text attachments saved to the client. Empty for the portal root. Used unless a folder was chosen when saving.",
            "nullable": true
          },
          "savedAttachments_PortalSameAsStorage": {
            "type": "boolean",
            "description": "Whether email, WhatsApp and text attachments saved to the client appear in the portal in the same folder as in storage, instead of SavedAttachments_PortalPath"
          }
        },
        "additionalProperties": false,
        "description": "Replaces where the practice's client documents are filed. Every field is sent. Paths are\n\"/\"-separated and may hold Liquid tokens; one that does not parse is refused."
      },
      "UpdateDocumentRequestItemListRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "What staff pick it by (at most 200 characters)"
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "What the list is for (at most 500 characters)",
            "nullable": true
          },
          "items": {
            "maxItems": 250,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestStepItemDto"
            },
            "description": "The items, in order (at most 250, as on a request); each needs text of at most 1,000 characters",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether \"Use a saved list\" offers it. Defaults to true."
          }
        },
        "additionalProperties": false,
        "description": "A saved list's new name, description, items and active flag (a full replacement)"
      },
      "UpdateDocumentRequestRequest": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "Title describing what documents are needed",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Detailed description of what is needed",
            "nullable": true
          },
          "deadline": {
            "type": "string",
            "description": "Optional deadline for the client to respond by",
            "format": "date",
            "nullable": true
          },
          "notifyUserCode": {
            "type": "string",
            "description": "Code of the user to notify when a submission is made",
            "nullable": true
          },
          "storageFolderPath": {
            "maxLength": 400,
            "type": "string",
            "description": "Where the request's files are stored, under the client's storage folder, instead of the practice's filing\nfolder for request uploads. May hold tokens (client, dates, Request.Code). Set with the portal folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          },
          "portalFolderPath": {
            "maxLength": 400,
            "type": "string",
            "description": "The client portal folder the request's files are filed in, instead of the practice's filing folder for request\nuploads. May hold tokens. Set with the storage folder: while both are null the practice's folders apply; once either is set, a null one (or \"/\") is the top folder.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a document request (only allowed while in Draft status)"
      },
      "UpdateDocumentTemplateRequest": {
        "required": [
          "bodyHtml",
          "name",
          "type"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 120,
            "minLength": 1,
            "type": "string",
            "description": "Display name for the template (e.g., \"Standard Engagement Letter\", \"Monthly Report\")"
          },
          "type": {
            "$ref": "#/components/schemas/TemplateType"
          },
          "bodyHtml": {
            "minLength": 1,
            "type": "string",
            "description": "Template body in HTML with Liquid syntax tokens.\nSupported tokens:\n- {{ client.name }} - Client's name\n- {{ client.companyNumber }} - Company registration number\n- {{ tenant.name }} - Your practice name\n- {{ date | date: \"%B %d, %Y\" }} - Current date (formatted)\n- {{ contentBlock \"block-code\" }} - Include a reusable content block\n- {% if client.isVatRegistered %} ... {% endif %} - Conditional content\n- {% for item in services %} ... {% endfor %} - Loop through collections\nCustom tokens can be passed via the Data parameter when rendering."
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional description explaining the template's purpose and usage",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether this template is available for use. Set to false to disable without deleting."
          },
          "outputNameTemplate": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional template for naming rendered documents.\nSupports {{ token }} placeholders (e.g. \"Engagement Letter - {{ ClientName }} - {{ Month }} {{ Year }}\").\nWhen null or empty, documents use the template's Name.",
            "nullable": true
          },
          "defaultDesignThemeCode": {
            "type": "string",
            "description": "Code of the default design theme to apply when rendering this template.\nIf not specified, falls back to the tenant's default theme.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpdateEmailBroadcastRequest": {
        "type": "object",
        "properties": {
          "contentBlockCode": {
            "maxLength": 100,
            "type": "string",
            "description": "Content block code (category: Email) used as the email template.\nMutually exclusive with SubjectLine/BodyHtml — provide one or the other.",
            "nullable": true,
            "example": "client-newsletter"
          },
          "subjectLine": {
            "maxLength": 500,
            "type": "string",
            "description": "Inline email subject line with Liquid template syntax.\nMust be provided together with BodyHtml. Mutually exclusive with ContentBlockCode.",
            "nullable": true,
            "example": "An update for {{ Client.Name }}"
          },
          "bodyHtml": {
            "type": "string",
            "description": "Inline email body HTML with Liquid template syntax.\nMust be provided together with SubjectLine. Mutually exclusive with ContentBlockCode.",
            "nullable": true
          },
          "allContacts": {
            "type": "boolean",
            "description": "When true, every contact of each client with an email address receives the email\nas a To recipient, regardless of contact type. RecipientContactTypes is ignored.",
            "example": false
          },
          "recipientIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include each client's business email (the email address on the client\nrecord) as a To recipient. Applies whether or not AllContacts is set."
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for To recipients, resolved per client at send time.\nIgnored when AllContacts is true.",
            "nullable": true
          },
          "recipientUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for To recipients (ClientManager, ClientPartner, ClientAssociate, ClientServiceManager),\nresolved per client at send time. TaskOwner and SpecificUser are not applicable for broadcasts.",
            "nullable": true
          },
          "additionalEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to include as To recipients on every email.",
            "nullable": true
          },
          "ccIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include each client's business email as a CC recipient."
          },
          "ccContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for CC recipients.",
            "nullable": true
          },
          "ccUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for CC recipients.",
            "nullable": true
          },
          "ccEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to include as CC recipients on every email.",
            "nullable": true
          },
          "bccIncludeBusinessEmail": {
            "type": "boolean",
            "description": "Whether to include each client's business email as a BCC recipient."
          },
          "bccContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "Client contact types for BCC recipients.",
            "nullable": true
          },
          "bccUserTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAssignmentType"
            },
            "description": "User types for BCC recipients.",
            "nullable": true
          },
          "bccEmailAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Static email addresses to include as BCC recipients on every email.",
            "nullable": true
          },
          "savedViewCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The code of a saved client view whose filter selects which clients to include.\nThe view's criteria are resolved when recipients are resolved, so later changes to\nthe view are picked up until the broadcast is sent. Mutually exclusive with Filter.",
            "nullable": true,
            "example": "active-limited-companies"
          },
          "filter": {
            "$ref": "#/components/schemas/EmailBroadcastFilterDto"
          },
          "excludedClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Client codes to exclude from the filter results.",
            "nullable": true
          },
          "additionalClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hand-picked client codes to add on top of the filter results.",
            "nullable": true
          },
          "onlyEmailableClients": {
            "type": "boolean",
            "description": "When true (default), clients whose email contact preference is not set are skipped.",
            "example": true
          },
          "sendOncePerAddress": {
            "type": "boolean",
            "description": "When true, a contact address on several selected clients gets one copy (the first client's).\nTeam and fixed addresses still go on every client's email.",
            "example": false
          },
          "practiceDocumentCodes": {
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of practice documents (tenant document library) attached to every email\nin the broadcast. Resolved to file content server-side at send time, so the\nbrowser never round-trips the document bytes.",
            "nullable": true
          },
          "addHeaderFooter": {
            "type": "boolean",
            "description": "When true (default), the tenant's email header and footer content blocks are\nwrapped around the body when the email is rendered.",
            "example": true
          },
          "configCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The email configuration (mailbox) code to send from.\nOmit to use the tenant's default mailbox resolution.",
            "nullable": true,
            "example": "billing-mailbox"
          }
        },
        "additionalProperties": false,
        "description": "Request to update a draft email broadcast.\nPUT is a full replacement — all fields are applied as provided.\nOnly broadcasts with status Draft can be updated.\nSame shape as the create request."
      },
      "UpdateEmailConfigRequest": {
        "type": "object",
        "properties": {
          "fromEmail": {
            "type": "string",
            "description": "Updated sender email address (optional, null to keep existing).\nCannot be changed on OAuth configurations that are currently connected.",
            "nullable": true
          },
          "fromName": {
            "type": "string",
            "description": "Updated sender display name (optional, null to keep existing)",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether to set this as the tenant's default email configuration.\nCannot be true unless IsSendShared is also true. Null to keep existing.",
            "nullable": true
          },
          "isSendShared": {
            "type": "boolean",
            "description": "Whether all users in the tenant can send emails from this configuration.\nCannot be set to false on the current default config. Null to keep existing.",
            "nullable": true
          },
          "readSharing": {
            "$ref": "#/components/schemas/MailboxReadSharing"
          },
          "shareClientEmails": {
            "type": "boolean",
            "description": "With ReadSharing Selected, whether colleagues also see every email with a client. Only the\nowner can change it. Null to keep existing. Saved as false whenever the effective\nread-sharing is not Selected.",
            "nullable": true
          },
          "signature": {
            "type": "string",
            "description": "Updated HTML email signature (empty string to clear, null to keep existing)",
            "nullable": true
          },
          "quoteOriginalInReplies": {
            "type": "boolean",
            "description": "Whether a reply sent from this mailbox carries the email it answers, quoted, below the reply's\ntext. Null to keep existing.",
            "nullable": true
          },
          "smtpSettings": {
            "$ref": "#/components/schemas/SmtpSettingsRequest"
          },
          "oAuthSettings": {
            "$ref": "#/components/schemas/OAuthSettingsRequest"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating an existing email configuration"
      },
      "UpdateEmailSettingsRequest": {
        "type": "object",
        "properties": {
          "emailHeaderContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to include at the top of emails",
            "nullable": true
          },
          "emailFooterContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to include at the bottom of emails",
            "nullable": true
          },
          "designThemeCode": {
            "type": "string",
            "description": "Code of the design theme to apply for email styling",
            "nullable": true
          },
          "replyToEmail": {
            "type": "string",
            "description": "Reply-to email address for system emails",
            "format": "email",
            "nullable": true
          },
          "replyToName": {
            "type": "string",
            "description": "Reply-to display name for system emails",
            "nullable": true
          },
          "clientEmailSender": {
            "$ref": "#/components/schemas/ClientEmailSender"
          },
          "allowSenderOverride": {
            "type": "boolean",
            "description": "Whether the person sending may choose another mailbox they can send from, where a send screen offers the\nchoice (an HMRC authorisation request, a proposal)."
          }
        },
        "additionalProperties": false,
        "description": "Request to update email settings for the tenant"
      },
      "UpdateEmailTriageSettingsRequest": {
        "type": "object",
        "properties": {
          "isEnabled": {
            "type": "boolean",
            "description": "Whether triage is switched on for the mailbox. Needs a connection that receives emails."
          },
          "defaultStatusCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The status code new conversations start at. Required while triage is on; must be an active\nstatus that does not mean Done.",
            "nullable": true
          },
          "defaultAssigneeType": {
            "$ref": "#/components/schemas/EmailTriageAssigneeType"
          },
          "defaultAssigneeUserCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The user new conversations are assigned to, with SpecificUser only (ignored otherwise). Must be\nsomeone who can read the mailbox.",
            "nullable": true
          },
          "enabledFrom": {
            "type": "string",
            "description": "With triage on: the date it counts from. Earlier mail is history (shows as done); later mail, already\nin the mailbox or still to come, gets the default status and assignee. Not in the future. Omitted, a\nmailbox already on keeps its date and one being switched on starts today (now).",
            "format": "date",
            "nullable": true
          },
          "tint": {
            "maxLength": 20,
            "type": "string",
            "description": "The colour to tint the mailbox's triage panel, as #RRGGBB (e.g. \"#3B82F6\"). Empty or omitted for none.",
            "nullable": true
          },
          "assigneeUserCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Who can be assigned the mailbox's conversations, by user code. Null or omitted for everyone who can\nread the mailbox in full; otherwise only these, each of whom must be able to read it. Not empty.",
            "nullable": true
          },
          "showServiceStages": {
            "type": "boolean",
            "description": "Whether the email page shows the stages of the matched client's services beside its conversations."
          },
          "summaries": {
            "type": "boolean",
            "description": "Whether the email page shows a summary box on the mailbox's conversations. Omitted, it is on."
          },
          "aiSummaries": {
            "type": "boolean",
            "description": "Whether the summary box offers to generate the summary with AI; only takes effect while\nSodiumHQ.DTOs.EmailConfig.UpdateEmailTriageSettingsRequest.Summaries is on. Omitted, it is on."
          },
          "assignOnStatusChange": {
            "type": "boolean",
            "description": "Whether setting the status of an unassigned conversation also assigns it to the person who set it, when\nthey can be assigned it. Omitted, it is off."
          }
        },
        "additionalProperties": false,
        "description": "Request to save a mailbox's email triage settings (docs/features/EmailTriage/PLAN.md D16). A full\nreplacement of the settings."
      },
      "UpdateEmailTriageStatusRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name, e.g. \"Waiting on client\""
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position in the status picker",
            "format": "int32"
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the status is offered when setting a conversation's status (default true)"
          },
          "color": {
            "maxLength": 20,
            "type": "string",
            "description": "Display colour, e.g. \"#3B82F6\"",
            "nullable": true
          },
          "isDone": {
            "type": "boolean",
            "description": "Whether the status closes a conversation"
          },
          "archiveOnDone": {
            "type": "boolean",
            "description": "Whether setting this status also archives the conversation in Outlook or Gmail. Only allowed with IsDone."
          },
          "archiveFolderName": {
            "maxLength": 255,
            "type": "string",
            "description": "With ArchiveOnDone: the folder path (Gmail: label name) to move the conversation to, matched ignoring case in\neach mailbox; a mailbox without it is left alone. Null or blank for the mailbox's archive. Omitting it clears it.",
            "nullable": true
          },
          "offerOnSend": {
            "type": "boolean",
            "description": "Whether the reply Send button offers this status (\"Send & Done\"). Any status may be offered."
          },
          "onReplyStatusCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The status a client's reply moves the conversation to: an active status that does not mean Done, or\nthis status's own code on a Done status to keep it Done. Null: back to the mailbox's default status for\na Done status, no move for an open one. Omitting it clears the rule (a full replacement).",
            "nullable": true
          },
          "bringBackEnabled": {
            "type": "boolean",
            "description": "Whether setting this status also brings the conversation back to SodiumHQ.DTOs.EmailTriage.UpdateEmailTriageStatusRequest.BringBackStatusCode after\nSodiumHQ.DTOs.EmailTriage.UpdateEmailTriageStatusRequest.BringBackDays, if nothing has changed its status by then. Switched off, the days and target are\ncleared; omitting it switches it off (a full replacement)."
          },
          "bringBackDays": {
            "maximum": 365,
            "minimum": 1,
            "type": "integer",
            "description": "With SodiumHQ.DTOs.EmailTriage.UpdateEmailTriageStatusRequest.BringBackEnabled: the default number of days before the conversation is brought back (1 to 365)",
            "format": "int32",
            "nullable": true
          },
          "bringBackStatusCode": {
            "maxLength": 100,
            "type": "string",
            "description": "With SodiumHQ.DTOs.EmailTriage.UpdateEmailTriageStatusRequest.BringBackEnabled: the default status to bring the conversation back to, an active status that\ndoes not mean Done and is not this one",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update an email triage status (a full replacement). At least one active status must\nstay Done, and a mailbox's default status must stay active and not Done."
      },
      "UpdateEngagementCustomTokenValuesRequest": {
        "required": [
          "values"
        ],
        "type": "object",
        "properties": {
          "values": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Values keyed as the template's token list names them (e.g. \"Custom.FeeNotes\"). Replaces the stored\nset; an empty object clears it."
          }
        },
        "additionalProperties": false,
        "description": "The custom token values to render an engagement's proposal and letter with."
      },
      "UpdateEngagementRequest": {
        "required": [
          "clientCode",
          "date"
        ],
        "type": "object",
        "properties": {
          "clientCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the client this engagement belongs to"
          },
          "date": {
            "type": "string",
            "description": "Date of the engagement",
            "format": "date"
          },
          "status": {
            "$ref": "#/components/schemas/EngagementStatus"
          },
          "type": {
            "$ref": "#/components/schemas/EngagementType"
          },
          "manuallyAccepted": {
            "type": "boolean",
            "description": "Indicates whether the engagement was manually accepted (true) or accepted via the online acceptance page (false).\nOnly relevant when Status is set to Accepted.",
            "nullable": true
          },
          "recipientFirstName": {
            "type": "string",
            "description": "First name of the recipient for this engagement",
            "nullable": true
          },
          "recipientLastName": {
            "type": "string",
            "description": "Last name of the recipient for this engagement",
            "nullable": true
          },
          "recipientEmail": {
            "type": "string",
            "description": "Email address of the recipient for this engagement",
            "nullable": true
          },
          "requestDdMandate": {
            "type": "boolean",
            "description": "Per-proposal override for the \"set up Direct Debit\" acceptance step, set on the send screen.\nNull leaves the practice default (from proposal settings) in effect for this proposal.",
            "nullable": true
          },
          "requestAmlOnboarding": {
            "type": "boolean",
            "description": "Per-proposal override for the identity-verification (AML) acceptance step, set on the send screen.\nNull leaves the practice default (from proposal settings) in effect for this proposal.",
            "nullable": true
          },
          "showPricingSummary": {
            "type": "boolean",
            "description": "Per-proposal override for showing the pricing summary panel on the acceptance page.\nNull leaves the practice default (from proposal settings) in effect for this proposal.",
            "nullable": true
          },
          "excludedDataFormCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the forms configured in proposal settings that this proposal opts out of.\nEmpty leaves every configured form in effect for this proposal; omit to keep the stored value.",
            "nullable": true
          },
          "proposalTemplateCode": {
            "type": "string",
            "description": "Code of the template to use for the proposal document",
            "nullable": true
          },
          "lofETemplateCode": {
            "type": "string",
            "description": "Code of the template to use for the letter of engagement (LofE) document",
            "nullable": true
          },
          "clientBillableServiceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "List of ClientBillableService codes to include in this engagement.\n            \nIMPORTANT: Updating this field will replace ALL existing service snapshots with new ones.\nThe system will create fresh snapshots of each ClientBillableService at its current state.\nThis allows you to update the engagement if service pricing or details have changed.\n            \nThe historical snapshots are stored as JSON and preserve service details even if the original\nClientBillableService is later modified or deleted.\n            \nExample: [\"CBS001\", \"CBS002\", \"CBS003\"]",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating an existing engagement"
      },
      "UpdateEngagementSettingsDataFormRequest": {
        "required": [
          "dataFormCode",
          "stepTitle"
        ],
        "type": "object",
        "properties": {
          "dataFormCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the form to present. Must be a published form."
          },
          "stepTitle": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The label shown for this step in the progress bar at the top of the acceptance flow"
          },
          "stepDescription": {
            "maxLength": 200,
            "type": "string",
            "description": "Short text shown under the step label in the progress bar",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position of this form among the form steps. Lower sorts first.",
            "format": "int32"
          },
          "isSkippable": {
            "type": "boolean",
            "description": "Whether the client can move past this step without completing the form"
          }
        },
        "additionalProperties": false,
        "description": "Request to configure a form as a step in the proposal acceptance flow."
      },
      "UpdateEngagementSettingsRequest": {
        "required": [
          "catchUpFeeLabel"
        ],
        "type": "object",
        "properties": {
          "introContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to display at the start of engagement acceptance pages",
            "nullable": true
          },
          "thankYouContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to display after engagement acceptance",
            "nullable": true
          },
          "emailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to include in the engagement email body",
            "nullable": true
          },
          "acceptanceTaskCode": {
            "type": "string",
            "description": "Code of the one-off task template to create a task from when an engagement is accepted",
            "nullable": true
          },
          "notifyClientManagerOnAcceptance": {
            "type": "boolean",
            "description": "Whether to send an email notification to the client manager when an engagement is accepted"
          },
          "notifyPartnerOnAcceptance": {
            "type": "boolean",
            "description": "Whether to send an email notification to the partner when an engagement is accepted"
          },
          "designThemeCode": {
            "type": "string",
            "description": "Code of the design theme to apply to engagement documents and acceptance pages",
            "nullable": true
          },
          "showPracticeName": {
            "type": "boolean",
            "description": "Whether to display the practice name on engagement acceptance pages and documents"
          },
          "showPricingSummary": {
            "type": "boolean",
            "description": "Whether to show the pricing summary panel on the proposal acceptance page"
          },
          "catchUpFeeLabel": {
            "maxLength": 50,
            "minLength": 1,
            "type": "string",
            "description": "How the practice names a catch-up fee wherever one is shown. Required: the request is a full\nreplacement, so send the current label back to keep it."
          },
          "attachPDFs": {
            "type": "boolean",
            "description": "Whether to attach engagement PDFs to the engagement email"
          },
          "thankYouEmailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use for thank you email sent to client after engagement acceptance",
            "nullable": true
          },
          "requestDdMandate": {
            "type": "boolean",
            "description": "Whether to request a Direct Debit mandate when engagement is accepted"
          },
          "requestAmlOnboarding": {
            "type": "boolean",
            "description": "Whether to request AML onboarding for the main contact when engagement is accepted"
          },
          "amlOnboardingLevelId": {
            "type": "string",
            "description": "The AML platform onboarding level ID to use when creating the onboarding request",
            "nullable": true
          },
          "signaturePageContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use as the signature page in engagement documents",
            "nullable": true
          },
          "useThirdPartyProposalPlatform": {
            "type": "boolean",
            "description": "Whether to use a third-party platform (e.g., Socket) for proposals instead of native Sodium proposals"
          },
          "addToPipelineOnSend": {
            "type": "boolean",
            "description": "Whether to add the client to a sales pipeline when their proposal is first sent"
          },
          "onSendPipelineCode": {
            "type": "string",
            "description": "Code of the sales pipeline clients are added to when their proposal is first sent",
            "nullable": true
          },
          "dataForms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UpdateEngagementSettingsDataFormRequest"
            },
            "description": "Forms to present as steps in the acceptance flow. Full replacement — omitting a form removes it.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update engagement settings for the tenant"
      },
      "UpdateFilingCreditSettingsRequest": {
        "type": "object",
        "properties": {
          "autoTopUp": {
            "$ref": "#/components/schemas/FilingCreditAutoTopUpDto"
          }
        },
        "additionalProperties": false,
        "description": "Replaces the practice's automatic top-up; null switches it off. Switching it on needs a Direct Debit\n(409 billing_mandate_required)."
      },
      "UpdateHmrcAgentCredentialRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "What the practice calls this set. Unique within the practice."
          },
          "agentReferenceNumber": {
            "maxLength": 20,
            "type": "string",
            "description": "Agent Reference Number (ARN) from the Agent Services Account.",
            "nullable": true
          },
          "saAgentCode": {
            "maxLength": 20,
            "type": "string",
            "description": "Self Assessment agent code (e.g. A12345).",
            "nullable": true
          },
          "payeAgentCode": {
            "maxLength": 20,
            "type": "string",
            "description": "PAYE/CIS agent code (e.g. 123/A12345).",
            "nullable": true
          },
          "ctAgentCode": {
            "maxLength": 20,
            "type": "string",
            "description": "Corporation Tax agent code.",
            "nullable": true
          },
          "contactFirstName": {
            "maxLength": 50,
            "type": "string",
            "description": "First name of the agent contact.",
            "nullable": true
          },
          "contactLastName": {
            "maxLength": 50,
            "type": "string",
            "description": "Last name of the agent contact.",
            "nullable": true
          },
          "contactEmail": {
            "maxLength": 150,
            "type": "string",
            "description": "Email of the agent contact.",
            "format": "email",
            "nullable": true
          },
          "govGatewayUserId": {
            "maxLength": 30,
            "type": "string",
            "description": "Government Gateway user ID.",
            "nullable": true
          },
          "govGatewayPassword": {
            "maxLength": 100,
            "type": "string",
            "description": "Government Gateway password (write-only). Set to update, empty string to clear, null to leave unchanged.",
            "nullable": true
          },
          "useTestGateway": {
            "type": "boolean",
            "description": "CIS Manager files this set's returns with HMRC's test gateway, not the live one."
          },
          "testInLive": {
            "type": "boolean",
            "description": "CIS Manager flags this set's live returns as tests. Ignored (stored false) with the test gateway."
          }
        },
        "additionalProperties": false,
        "description": "Replaces a credential set's fields. The password follows the null/empty/value rule."
      },
      "UpdateImageAssetRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name for the image asset",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional description of the image asset",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update an existing image asset"
      },
      "UpdateMailboxDraftRequest": {
        "required": [
          "htmlBody"
        ],
        "type": "object",
        "properties": {
          "subject": {
            "type": "string",
            "description": "Subject line",
            "nullable": true
          },
          "plainTextBody": {
            "type": "string",
            "description": "Plain text body (optional fallback)",
            "nullable": true
          },
          "toRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "To recipients — the draft's full To list",
            "nullable": true
          },
          "ccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "CC recipients — the draft's full CC list",
            "nullable": true
          },
          "bccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailRecipientDto"
            },
            "description": "BCC recipients — the draft's full BCC list",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAttachmentDto"
            },
            "description": "Attachments the saved draft should have. Null = leave the draft's existing attachments\nuntouched (no attachment changes made in this edit). Empty list = remove every attachment.\nA populated list replaces the attachment set outright.",
            "nullable": true
          },
          "keepAttachmentIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ids (from the draft's current attachment list) of existing attachments to keep. Only\nconsulted when the edit changes attachments at all — omit both this and Attachments to\nleave every existing attachment untouched.",
            "nullable": true
          },
          "htmlBody": {
            "minLength": 1,
            "type": "string",
            "description": "HTML body of the draft. Redeclared from the email service contract so it is cleaned as the request is read."
          },
          "practiceDocumentCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of practice documents (tenant document library) to attach. Resolved to file\ncontent server-side, same as create and send.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update a mailbox draft, extending the email service contract with references to\nexisting draft attachments to keep unchanged. Resolved to content server-side so the browser\nnever has to re-download and re-upload bytes for attachments the user didn't touch."
      },
      "UpdateMeetingNoteRequest": {
        "required": [
          "medium",
          "startTime",
          "title"
        ],
        "type": "object",
        "properties": {
          "title": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "Short plain-text title, e.g. \"Missed call from Jane Smith\""
          },
          "startTime": {
            "type": "string",
            "description": "When the meeting started, ISO 8601 with a time zone (Z or an offset); stored as UTC. A time with no zone is\nrejected rather than guessed at.",
            "format": "date-time"
          },
          "endTime": {
            "type": "string",
            "description": "When the meeting ended, as for StartTime. Not before StartTime.",
            "format": "date-time",
            "nullable": true
          },
          "medium": {
            "$ref": "#/components/schemas/MeetingMedium"
          },
          "summary": {
            "type": "string",
            "description": "Summary, HTML. A value with no HTML tags is taken as plain text: encoded, with line breaks kept.",
            "nullable": true
          },
          "content": {
            "type": "string",
            "description": "The full content, usually a transcript, HTML. A value with no HTML tags is taken as plain text: encoded, with\nline breaks kept.",
            "nullable": true
          },
          "taskItemCode": {
            "type": "string",
            "description": "The code of the client's task the meeting was about. Must be one of the client's tasks.",
            "nullable": true
          },
          "contactCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the client contacts who attended. Each must be linked to the client. Replaces the list on update.",
            "nullable": true
          },
          "userCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Codes of the staff who attended. Replaces the list on update.",
            "nullable": true
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MeetingNoteLinkDto"
            },
            "description": "Links to outside resources, such as the recording, in display order. Replaces the list on update.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update a meeting note. A full replacement: the attendee and link lists sent replace the stored ones\n(an attendee who has since been deleted is kept, by name)."
      },
      "UpdateMessagingCreditSettingsRequest": {
        "type": "object",
        "properties": {
          "autoTopUp": {
            "$ref": "#/components/schemas/MessagingAutoTopUpDto"
          },
          "lowCreditAlertBelow": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "Tell the practice's messaging admins when the balance falls below this; null for off",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Replaces the practice's automatic top-up and low-credit alert; null switches either off. Switching automatic top-up\non needs a Direct Debit (409 billing_mandate_required)."
      },
      "UpdateMessagingQuietHoursRequest": {
        "required": [
          "enabled",
          "end",
          "start"
        ],
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Whether automatic texts wait during the window"
          },
          "start": {
            "type": "string",
            "description": "When the window starts (UK time)",
            "format": "time"
          },
          "end": {
            "type": "string",
            "description": "When the window ends (UK time); earlier than the start for a window that crosses midnight",
            "format": "time"
          }
        },
        "additionalProperties": false,
        "description": "Replaces the practice's quiet hours for automatic texts. Start and end may not be equal."
      },
      "UpdateMessagingRequestTextRoutingRequest": {
        "required": [
          "routing"
        ],
        "type": "object",
        "properties": {
          "routing": {
            "$ref": "#/components/schemas/MessagingRequestTextRouting"
          }
        },
        "additionalProperties": false,
        "description": "Replaces how the practice's request texts choose between WhatsApp and SMS"
      },
      "UpdateMessagingTemplateRequest": {
        "required": [
          "body",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "What staff pick it by; unique in the practice"
          },
          "body": {
            "maxLength": 1600,
            "minLength": 1,
            "type": "string",
            "description": "The text with Liquid tokens, at most 1,600 characters (the SMS limit). A token that does not parse\nis a 400 on body."
          }
        },
        "additionalProperties": false,
        "description": "A practice text template's new name and body (a full replacement)"
      },
      "UpdateMessagingTextWordingsRequest": {
        "required": [
          "chase",
          "cisPayments",
          "clientConfirmation",
          "dataForm",
          "documentApproval",
          "documentRequest"
        ],
        "type": "object",
        "properties": {
          "documentRequest": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "For a document request"
          },
          "documentApproval": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "For documents to approve"
          },
          "clientConfirmation": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "For something to confirm: a client confirmation, or a CIS return"
          },
          "dataForm": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "For a form"
          },
          "cisPayments": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "For the CIS payments page"
          },
          "chase": {
            "maxLength": 500,
            "minLength": 1,
            "type": "string",
            "description": "For the chase's text: {{ Url }} is the portal's address, {{ Outstanding }} what is outstanding (\"3 things\")"
          }
        },
        "additionalProperties": false,
        "description": "Replaces the practice's wording for the text a client send step can add to its email. Every wording must carry\n{{ Url }}; one equal to its default is kept as the default."
      },
      "UpdateMtdForeignPropertyRequest": {
        "required": [
          "propertyName"
        ],
        "type": "object",
        "properties": {
          "propertyName": {
            "maxLength": 105,
            "minLength": 1,
            "type": "string",
            "description": "The property's name. HMRC require it even when only the end date is changing."
          },
          "endDate": {
            "type": "string",
            "description": "When income stopped being received. Must be paired with Sodium.HmrcMtd.Product.Contracts.Dtos.UpdateMtdForeignPropertyRequest.EndReason, and cannot\nfall after the end of the tax year being updated.",
            "format": "date",
            "nullable": true
          },
          "endReason": {
            "$ref": "#/components/schemas/ForeignPropertyEndReason"
          }
        },
        "additionalProperties": false,
        "description": "Renames a registered foreign property, or records that it stopped producing income.\n            \nThe country cannot be changed: a property registered against the wrong country is ended with\nSodium.HmrcMtd.Contracts.Enums.ForeignPropertyEndReason.AddedInError and registered again, because figures\nalready filed against it are keyed by its identifier."
      },
      "UpdateMyOtherEmailAddressesRequest": {
        "required": [
          "emails"
        ],
        "type": "object",
        "properties": {
          "emails": {
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The whole list of their other addresses; an empty list removes them all"
          }
        },
        "additionalProperties": false,
        "description": "Replaces the signed-in team member's other email addresses"
      },
      "UpdateNewMailAlertRequest": {
        "type": "object",
        "properties": {
          "scope": {
            "$ref": "#/components/schemas/NewMailAlertScope"
          }
        },
        "additionalProperties": false,
        "description": "Request to set the current user's new-mail alert on a mailbox"
      },
      "UpdateOnboardingTaskTemplateRequest": {
        "required": [
          "billableServiceCode"
        ],
        "type": "object",
        "properties": {
          "billableServiceCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the billable service this template belongs to"
          },
          "name": {
            "type": "string",
            "description": "The name of the onboarding task",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The description of the onboarding task",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "dueDateOffsetDays": {
            "type": "integer",
            "description": "Days after service start date for the task due date",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day stamped onto the start date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day stamped onto the due date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Code of the user to assign tasks to (only used if AssignmentType is SpecificUser)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "Code of the team to assign tasks to (optional, independent of AssignmentType)",
            "nullable": true
          },
          "workflowCode": {
            "type": "string",
            "description": "Code of the workflow template to apply to generated tasks",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "Code of the category to apply to generated tasks",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this onboarding task template",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this template is active"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating an onboarding task template"
      },
      "UpdateOutboundWebhookRequest": {
        "required": [
          "eventTypes",
          "isEnabled",
          "name",
          "payloadMode",
          "url"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "What the practice calls it. 1 to 100 characters."
          },
          "url": {
            "maxLength": 2048,
            "minLength": 1,
            "type": "string",
            "description": "Where events are posted: an absolute `https` URL of at most 2048 characters, with no user info."
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The event types it wants, from the catalogue (`GET /metadata/outbound-webhook-event-types`), or `*`\nalone for every event, including ones added later."
          },
          "payloadMode": {
            "$ref": "#/components/schemas/OutboundWebhookPayloadMode"
          },
          "isEnabled": {
            "type": "boolean",
            "description": "Whether events are sent to it. Switching it off cancels deliveries still waiting to be sent."
          }
        },
        "additionalProperties": false,
        "description": "A webhook as the practice replaces it (docs/features/Webhooks/PLAN.md D7): every field is set; the secret is kept."
      },
      "UpdatePersonalSignatureRequest": {
        "type": "object",
        "properties": {
          "signature": {
            "type": "string",
            "description": "The HTML signature. Null or blank removes it, so the mailbox's signature applies again.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to set the current user's own signature on a mailbox"
      },
      "UpdatePipelineOnboardingTaskTemplateRequest": {
        "required": [
          "pipelineCode"
        ],
        "type": "object",
        "properties": {
          "pipelineCode": {
            "minLength": 1,
            "type": "string",
            "description": "Code of the pipeline this template belongs to"
          },
          "name": {
            "type": "string",
            "description": "The name of the intake task",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The description of the intake task",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "dueDateOffsetDays": {
            "type": "integer",
            "description": "Days after the card's start date for the task due date",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day stamped onto the start date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day stamped onto the due date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Code of the user to assign tasks to (only used if AssignmentType is SpecificUser)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "Code of the team to assign tasks to (optional, independent of AssignmentType)",
            "nullable": true
          },
          "workflowCode": {
            "type": "string",
            "description": "Code of the workflow template to apply to generated tasks",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "Code of the category to apply to generated tasks",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this intake task template",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this template is active"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a pipeline intake task template"
      },
      "UpdatePipelineRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the pipeline"
          },
          "description": {
            "type": "string",
            "description": "The description of the pipeline",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "Indicates whether this pipeline is archived (inactive)"
          },
          "defaultManagedByUserCode": {
            "type": "string",
            "description": "The code of the user who is the default manager for this pipeline",
            "nullable": true
          },
          "showKanbanBoard": {
            "type": "boolean",
            "description": "Whether this pipeline should appear on the Boards kanban view"
          },
          "trackDealValue": {
            "type": "boolean",
            "description": "Whether cards on this pipeline carry a deal value and likelihood, with full and weighted totals on the board"
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PipelineStageDto"
            },
            "description": "User-defined stages for this pipeline",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating an existing sales pipeline (full replacement)"
      },
      "UpdatePortalUserStatusRequest": {
        "type": "object",
        "properties": {
          "isActive": {
            "type": "boolean",
            "description": "Whether the portal user should be active."
          }
        },
        "additionalProperties": false,
        "description": "Request to activate or deactivate a portal user."
      },
      "UpdatePracticeDetailsRequest": {
        "required": [
          "currencyCode",
          "locale",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "Official name of the accounting practice or firm"
          },
          "isVatRegistered": {
            "type": "boolean",
            "description": "Whether the practice is registered for VAT"
          },
          "vatNumber": {
            "maxLength": 20,
            "type": "string",
            "description": "The practice's own VAT registration number. When set, client VAT number checks against HMRC\nbecome verified checks and return a consultation number as proof of the check.",
            "nullable": true
          },
          "companyNumber": {
            "type": "string",
            "description": "Companies House registration number (if the practice is a limited company)",
            "nullable": true
          },
          "logoUrl": {
            "type": "string",
            "description": "URL to the practice logo image (from image assets)",
            "nullable": true
          },
          "address": {
            "type": "string",
            "description": "Practice physical/postal address",
            "nullable": true
          },
          "website": {
            "type": "string",
            "description": "Practice website URL",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "Practice email address for general inquiries",
            "format": "email",
            "nullable": true
          },
          "mobile": {
            "type": "string",
            "description": "Practice mobile phone number",
            "nullable": true
          },
          "telephone": {
            "type": "string",
            "description": "Practice landline telephone number",
            "nullable": true
          },
          "professionalBody": {
            "$ref": "#/components/schemas/ProfessionalBody"
          },
          "professionalBodyName": {
            "type": "string",
            "description": "Full name of the professional body (e.g. \"Institute of Chartered Accountants in England and Wales\"). Derived from ProfessionalBody.",
            "nullable": true,
            "readOnly": true
          },
          "professionalBodyWebsite": {
            "type": "string",
            "description": "Public website URL for the professional body (e.g. \"https://www.icaew.com\"). Derived from ProfessionalBody.",
            "nullable": true,
            "readOnly": true
          },
          "currencyCode": {
            "maxLength": 3,
            "minLength": 1,
            "type": "string",
            "description": "ISO 4217 currency code the practice bills in (e.g. \"GBP\"). Drives money formatting across\ndocuments, emails, the web app and the client portal. Defaults to GBP."
          },
          "locale": {
            "maxLength": 20,
            "minLength": 1,
            "type": "string",
            "description": "BCP 47 / .NET culture name (e.g. \"en-GB\") driving number grouping and date conventions.\nDefaults to en-GB."
          },
          "vatRegime": {
            "$ref": "#/components/schemas/VatRegime"
          },
          "logo": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "logoCode": {
            "type": "string",
            "description": "Code of the image asset to use as the practice logo",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update practice/firm details"
      },
      "UpdatePracticeDocumentRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "Name of the document"
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "Description of the document",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update a practice document's metadata (the file itself is immutable)"
      },
      "UpdatePracticeNoteRequest": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "The note content. Send an empty string to clear the note.",
            "nullable": true
          },
          "isRichText": {
            "type": "boolean",
            "description": "Whether SodiumHQ.DTOs.PracticeNote.UpdatePracticeNoteRequest.Text is HTML from the rich-text editor rather than plain text"
          },
          "expectedUpdatedDate": {
            "type": "string",
            "description": "The UpdatedDate this edit was made against. The save is rejected when somebody else has\nsaved since, so one user's edit cannot silently overwrite another's; send the rejected\nresponse's UpdatedDate back to overwrite theirs deliberately.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for saving the practice's shared note"
      },
      "UpdateProfessionalClearanceLetterSettingsRequest": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Whether professional clearance letter functionality is enabled for this tenant"
          },
          "emailContentBlockCode": {
            "type": "string",
            "description": "Code of the content block to use for email body",
            "nullable": true
          },
          "ccRecipientConfig": {
            "$ref": "#/components/schemas/EmailRecipientConfig"
          }
        },
        "additionalProperties": false,
        "description": "Request to update professional clearance letter settings for the tenant"
      },
      "UpdateProfessionalClearanceRequestItemRequest": {
        "type": "object",
        "properties": {
          "request": {
            "type": "string",
            "description": "The request text",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying the requests",
            "format": "int32"
          },
          "global": {
            "type": "boolean",
            "description": "If true, this item will be included for all clients regardless of the services they have"
          }
        },
        "additionalProperties": false,
        "description": "DTO for updating a professional clearance request item"
      },
      "UpdateRecurringTaskItemRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the recurring task",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The description of the recurring task",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Code of the user to assign tasks to (only used if AssignmentType is SpecificUser)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "Code of the team to assign tasks to (optional, independent of AssignmentType)",
            "nullable": true
          },
          "billableServiceCode": {
            "type": "string",
            "description": "Code of the billable service (only used if AssignmentType is ClientServiceManager, ClientServicePreparer or ClientServiceReviewer)",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Sort order for displaying recurring tasks",
            "format": "int32",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this recurring task is active and will generate new tasks"
          },
          "schedule": {
            "$ref": "#/components/schemas/ScheduleConfigDto"
          },
          "process": {
            "$ref": "#/components/schemas/ProcessConfigRequestDto"
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "categoryCode": {
            "type": "string",
            "description": "Code of the category to apply to generated tasks (optional)",
            "nullable": true
          },
          "clientAssociationType": {
            "$ref": "#/components/schemas/ClientAssociationType"
          },
          "vatReportingPeriod": {
            "$ref": "#/components/schemas/VatReportingPeriod"
          },
          "taskNameTemplate": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional template for naming tasks created from this recurring task.\nSupports {{ token }} placeholders (e.g. \"VAT Return - {{ ClientName }} - {{ Quarter }} {{ Year }}\").\nWhen null or empty, tasks use the recurring task's Name.\nAvailable tokens can be retrieved from the GET /metadata/task-name-tokens endpoint.\nUnrecognised tokens are left as-is in generated task names.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpdateRevenueRangeRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The display name of the revenue range (e.g., \"£30k - £70k\")",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying revenue ranges",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "DTO for updating a revenue range"
      },
      "UpdateRoleRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name of the role. Must be unique within the practice and cannot use a\nbuilt-in role name (Admin, Standard User, Viewer)."
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional description of what this role is for",
            "nullable": true
          },
          "permissions": {
            "type": "object",
            "properties": {
              "Tasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Users": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Clients": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Contacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientContacts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Reports": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Settings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ApiKeys": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Roles": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBillableServices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ServicePackages": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "RecurringTasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Workflows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ThirdPartyConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ContentBlocks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDetails": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DesignThemes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Templates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Engagements": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CustomFields": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Subscription": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientPortalSettings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DocumentRequests": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Billing": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientEmailRules": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Mailbox": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Teams": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "DataForms": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "KanbanBoards": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBilling": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailBroadcasts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeTracking": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Pipelines": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "PracticeDocuments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "WorkingPatterns": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalIncomeTax": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "MakingTaxDigitalTaxReturn": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooksConnections": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ClientBooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "BookkeepingHealth": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "CostRates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "ProductAccounts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "Messaging": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "TimeOff": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "EmailTriage": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "JobBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeBudgets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "OutboundWebhooks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              },
              "FeeOverrides": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Permission"
                }
              }
            },
            "additionalProperties": false,
            "description": "The capabilities to grant per entity. Capabilities are independent flags — include every\ncapability the role should have; \"Admin\" grants everything on that entity. Grants are capped\nat the capabilities the requesting user themselves holds on each entity: anything beyond\nthat is silently reduced, not rejected.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update a custom role. This is a full replacement — the role's name, description and\nentire permission set are overwritten with the values supplied."
      },
      "UpdateSalesPipelineSettingsRequest": {
        "type": "object",
        "properties": {
          "isEnabled": {
            "type": "boolean",
            "description": "Whether the Sales Pipeline feature is enabled for this tenant. Enabling it reveals the\npipeline UI, runs pipeline automations for Active Prospects, and includes Active Prospects\nin the tenant's billable client count."
          }
        },
        "additionalProperties": false,
        "description": "Request to update the tenant's Sales Pipeline settings."
      },
      "UpdateSavedClientFilterRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "User-friendly name for this saved filter (e.g., \"Active Limited Companies\", \"My Managed Clients\")"
          },
          "description": {
            "maxLength": 1000,
            "type": "string",
            "description": "Optional description providing more details about this filter's purpose",
            "nullable": true
          },
          "includeInMenu": {
            "type": "boolean",
            "description": "Whether this filter should be included in the current user's menu/quick access list.\nThis is a per-user preference — it does not affect other users of a shared filter."
          },
          "isShared": {
            "type": "boolean",
            "description": "Whether this filter is shared with all users in the tenant. Shared filters are\nvisible (read-only) to everyone; only the owner can modify or delete them."
          },
          "managerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by manager code(s)",
            "nullable": true
          },
          "partnerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by partner code(s)",
            "nullable": true
          },
          "associateCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by associate code(s)",
            "nullable": true
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientStatus"
            },
            "description": "Filter by client status(es)",
            "nullable": true
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "Filter by client type(s)",
            "nullable": true
          },
          "serviceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by billable service code(s)",
            "nullable": true
          },
          "packageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by service package code(s)",
            "nullable": true
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by team code(s)",
            "nullable": true
          },
          "serviceStageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by service stage composite codes (format: \"serviceCode:stageCode\")",
            "nullable": true
          },
          "serviceStatuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceStatus"
            },
            "description": "Service statuses a client's service must have: the chosen service's, or any service's when no service or stage is filtered. Null means any status.",
            "nullable": true
          },
          "customFieldFilters": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by custom field composite values (format: \"fieldCode:value\", or \"fieldCode:\" for blank)",
            "nullable": true
          },
          "keyDateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "keyDateRange": {
            "$ref": "#/components/schemas/PresetDateRange"
          },
          "keyDateFrom": {
            "type": "string",
            "description": "Start of the key date window. Only set when KeyDateRange is CustomDateRange.",
            "format": "date",
            "nullable": true
          },
          "keyDateTo": {
            "type": "string",
            "description": "End of the key date window. Only set when KeyDateRange is CustomDateRange.",
            "format": "date",
            "nullable": true
          },
          "defaultSortKeyDateType": {
            "$ref": "#/components/schemas/ClientDateType"
          },
          "defaultSortField": {
            "$ref": "#/components/schemas/ClientSortField"
          },
          "defaultSortDesc": {
            "type": "boolean",
            "description": "Sort in descending order (true) or ascending order (false)",
            "nullable": true
          },
          "iconName": {
            "maxLength": 100,
            "type": "string",
            "description": "Optional Lucide icon name for visual identification (e.g., \"Calendar\", \"Users\", \"Star\")",
            "nullable": true
          },
          "color": {
            "maxLength": 7,
            "type": "string",
            "description": "Optional hex color for visual identification (e.g., \"#FF5733\")",
            "nullable": true
          },
          "columnConfigJson": {
            "type": "string",
            "description": "Optional JSON column configuration for the saved view.\nWhen set, overrides the user's default client column preferences.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request model for updating an existing saved client filter"
      },
      "UpdateSavedTaskFilterRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "User-friendly name for this saved filter (e.g., \"My Overdue Tasks\", \"Client ABC Tasks\")"
          },
          "description": {
            "maxLength": 1000,
            "type": "string",
            "description": "Optional description providing more details about this filter's purpose",
            "nullable": true
          },
          "includeInMenu": {
            "type": "boolean",
            "description": "Whether this filter should be included in the current user's menu/quick access list.\nThis is a per-user preference — it does not affect other users of a shared filter."
          },
          "isShared": {
            "type": "boolean",
            "description": "Whether this filter is shared with all users in the tenant. Shared filters are\nvisible (read-only) to everyone; only the owner can modify or delete them."
          },
          "dateRange": {
            "$ref": "#/components/schemas/PresetDateRange"
          },
          "startDate": {
            "type": "string",
            "description": "Custom start date (only used when DateRange = CustomDateRange)",
            "format": "date",
            "nullable": true
          },
          "endDate": {
            "type": "string",
            "description": "Custom end date (only used when DateRange = CustomDateRange)",
            "format": "date",
            "nullable": true
          },
          "dateBasis": {
            "$ref": "#/components/schemas/TaskDateBasis"
          },
          "clientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by client code(s)",
            "nullable": true
          },
          "userCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by user code(s)",
            "nullable": true
          },
          "recurringTaskCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by recurring task code(s)",
            "nullable": true
          },
          "categoryCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by category code(s)",
            "nullable": true
          },
          "serviceCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by billable service code(s)",
            "nullable": true
          },
          "serviceStageCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by billable service stage. Composite \"serviceCode:stageCode\" values, since a stage\ncode is only unique within its parent service.",
            "nullable": true
          },
          "teamCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by team code(s)",
            "nullable": true
          },
          "clientManagerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the primary client's manager (user codes). Clientless tasks never match.",
            "nullable": true
          },
          "clientPartnerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the primary client's partner (user codes). Clientless tasks never match.",
            "nullable": true
          },
          "clientAssociateCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the primary client's associate (user codes). Clientless tasks never match.",
            "nullable": true
          },
          "servicePreparerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the Preparer in force on the task's service (user codes). Tasks without one never match.",
            "nullable": true
          },
          "serviceReviewerCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by the Reviewer in force on the task's service (user codes). Tasks without one never match.",
            "nullable": true
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskItemStatus"
            },
            "description": "Filter by task status(es)",
            "nullable": true
          },
          "isOverdue": {
            "type": "boolean",
            "description": "Filter to only overdue tasks",
            "nullable": true
          },
          "isUnassigned": {
            "type": "boolean",
            "description": "Include tasks with no assigned user. Can be combined with UserCodes to show\ntasks that are either unassigned OR assigned to specific users.",
            "nullable": true
          },
          "isAutomationDisabled": {
            "type": "boolean",
            "description": "Filter by the automation switch: true for tasks with automation off, false for those with\nit on, null for both. Task previews are excluded whenever this is set.",
            "nullable": true
          },
          "includeProjected": {
            "type": "boolean",
            "description": "Include projected (virtual) tasks in the results"
          },
          "includeWorkflowSteps": {
            "type": "boolean",
            "description": "Include workflow steps in the results (Agenda mode)"
          },
          "defaultSortField": {
            "$ref": "#/components/schemas/TaskItemSortField"
          },
          "defaultSortDesc": {
            "type": "boolean",
            "description": "Sort in descending order (true) or ascending order (false)",
            "nullable": true
          },
          "iconName": {
            "maxLength": 100,
            "type": "string",
            "description": "Optional Lucide icon name for visual identification (e.g., \"Calendar\", \"Users\", \"Star\")",
            "nullable": true
          },
          "color": {
            "maxLength": 7,
            "type": "string",
            "description": "Optional hex color for visual identification (e.g., \"#FF5733\")",
            "nullable": true
          },
          "columnConfigJson": {
            "type": "string",
            "description": "Optional JSON column configuration for the saved view.\nWhen set, overrides the user's default task column preferences.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request model for updating an existing saved task filter"
      },
      "UpdateScheduledSendRequest": {
        "type": "object",
        "properties": {
          "scheduledAt": {
            "type": "string",
            "description": "The new UTC dispatch instant. Required, and must be in the future.\nNullable so an omitted value reports \"a scheduled time is required\" rather than binding\nto DateTime.MinValue and reporting \"must be in the future\".",
            "format": "date-time",
            "nullable": true
          },
          "payload": {
            "$ref": "#/components/schemas/ScheduledSendPayload"
          }
        },
        "additionalProperties": false,
        "description": "Reschedules a pending scheduled send and optionally replaces its editable payload content.\nOnly Scheduled and Failed rows can be updated."
      },
      "UpdateSecuritySettingsRequest": {
        "type": "object",
        "properties": {
          "requireMfa": {
            "type": "boolean",
            "description": "Whether every user of this practice must complete multi-factor authentication to use the web\napp. Turning it on challenges every user at their next login and signs out sessions that have\nnot completed MFA."
          },
          "allowApiKeys": {
            "type": "boolean",
            "description": "Whether API keys may be used to access this practice. Turning it off rejects every API-key\nrequest to this practice."
          }
        },
        "additionalProperties": false,
        "description": "Request to update the practice's security settings. A full replacement: both flags are required."
      },
      "UpdateServiceBudgetRequest": {
        "required": [
          "period"
        ],
        "type": "object",
        "properties": {
          "period": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "hoursMode": {
            "$ref": "#/components/schemas/StandardHoursMode"
          },
          "budgetMinutes": {
            "maximum": 1000000,
            "minimum": 1,
            "type": "integer",
            "description": "The standard hours in minutes per period; required when HoursMode is Fixed",
            "format": "int32",
            "nullable": true
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageFigureRequest"
            },
            "description": "Each stage's minutes, when the hours mode is ByStage",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Sets a service's budget period and standard hours. Fee fields are not part of it: the fee is\nsaved through its own endpoint, so saving the hours never touches it."
      },
      "UpdateServiceCategoryRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name of the service category"
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying service categories",
            "format": "int32"
          },
          "color": {
            "maxLength": 20,
            "type": "string",
            "description": "The color associated with this service category",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for updating a service category. Updating a system category records the change as a\nper-tenant customisation rather than altering the shared category."
      },
      "UpdateServiceFeeBudgetRequest": {
        "type": "object",
        "properties": {
          "feeMode": {
            "$ref": "#/components/schemas/StandardFeeMode"
          },
          "feeAmount": {
            "maximum": 10000000,
            "minimum": 0.01,
            "type": "number",
            "description": "The standard fee per period; required when FeeMode is Fixed",
            "format": "double",
            "nullable": true
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageFigureRequest"
            },
            "description": "Each stage's fee, when the fee mode is ByStage",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Sets a service's standard fee budget."
      },
      "UpdateServicePackageRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the service package"
          },
          "description": {
            "type": "string",
            "description": "Description of what this package includes",
            "nullable": true
          },
          "isArchived": {
            "type": "boolean",
            "description": "Whether this package is archived (inactive)"
          },
          "usePackagePricing": {
            "type": "boolean",
            "description": "Whether this package uses a single package-level price instead of summing individual item prices"
          },
          "packagePrice": {
            "type": "number",
            "description": "The flat price for the entire package. Required when UsePackagePricing is true.",
            "format": "double",
            "nullable": true
          },
          "packageBillingFrequency": {
            "$ref": "#/components/schemas/BillingFrequency"
          },
          "packageSetupFee": {
            "type": "number",
            "description": "Optional one-off setup fee for the package, billed once when the package is first invoiced.\nOnly used when UsePackagePricing is true. Null means no setup fee.",
            "format": "double",
            "nullable": true
          },
          "proposalContentCode": {
            "type": "string",
            "description": "The code of the proposal content block. Only used when UsePackagePricing is true.\nWhen set, overrides the individual content blocks defined on each service in the package.\nWhen null, proposals fall back to each service's own proposal content block.",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreateServicePackageItemRequest"
            },
            "description": "The services to include in this package",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a service package"
      },
      "UpdateSubscriptionBillingRequest": {
        "type": "object",
        "properties": {
          "additionalInvoiceRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceRecipient"
            },
            "description": "Additional email recipients for invoices.",
            "nullable": true
          },
          "billingAddress": {
            "$ref": "#/components/schemas/BillingAddress"
          }
        },
        "additionalProperties": false,
        "description": "Request to update billing address and invoice recipients.\nName and billing contact are not user-settable."
      },
      "UpdateTaskCategoryRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The display name of the task category",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "The sort order for displaying task categories",
            "format": "int32"
          },
          "color": {
            "type": "string",
            "description": "The color associated with this task category",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for updating a task category"
      },
      "UpdateTaskFocusConfigItemRequest": {
        "type": "object",
        "properties": {
          "savedTaskFilterCode": {
            "type": "string",
            "description": "The code of the saved task filter to reference",
            "nullable": true
          },
          "label": {
            "type": "string",
            "description": "Optional custom label for this item in the focus panel",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Sort order for display in the focus panel",
            "format": "int32"
          },
          "color": {
            "type": "string",
            "description": "Optional color for visual styling in the focus panel",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for a single item in the task focus panel configuration"
      },
      "UpdateTaskFocusConfigRequest": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UpdateTaskFocusConfigItemRequest"
            },
            "description": "The saved task filter items to display in the focus panel",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for upserting a user's task focus panel configuration"
      },
      "UpdateTaskItemNoteRequest": {
        "required": [
          "date",
          "noteFromUserCode",
          "text"
        ],
        "type": "object",
        "properties": {
          "text": {
            "minLength": 1,
            "type": "string",
            "description": "The text content of the note"
          },
          "date": {
            "type": "string",
            "description": "The date/time the note was created",
            "format": "date-time"
          },
          "noteFromUserCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the user who authored this note"
          },
          "pinnedLevel": {
            "type": "integer",
            "description": "The pinned level: 0 not pinned, 1 top of the notes section, 2 top of the client or task page, 3 the dashboard",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a task item note"
      },
      "UpdateTaskItemRequest": {
        "required": [
          "dueDate",
          "name",
          "startDate",
          "status"
        ],
        "type": "object",
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string",
            "description": "The name of the task"
          },
          "description": {
            "type": "string",
            "description": "The description of the task",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes.",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "startDate": {
            "type": "string",
            "description": "When the task starts",
            "format": "date"
          },
          "dueDate": {
            "type": "string",
            "description": "When the task is due",
            "format": "date"
          },
          "statutoryDueDate": {
            "type": "string",
            "description": "The statutory due date for compliance tasks (if applicable)",
            "format": "date",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "Time of day on the start date. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day on the due date. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "clientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the clients this task is associated with (optional)",
            "nullable": true
          },
          "primaryClientCode": {
            "type": "string",
            "description": "The code of the primary client for this task (optional)",
            "nullable": true
          },
          "assignedUserCode": {
            "type": "string",
            "description": "The code of the user to assign the task to (optional)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "The code of the team to assign the task to (optional)",
            "nullable": true
          },
          "clientBillableServiceCode": {
            "type": "string",
            "description": "The code of the client billable service this task relates to (optional)",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "The code of the category for this task (optional)",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this task",
            "nullable": true
          },
          "isAutomationDisabled": {
            "type": "boolean",
            "description": "Automation switch. On create, null lets Sodium decide: a task starting today or in the past\nlands with automation off, so creating it never runs workflow steps as a side effect. An\nexplicit value wins over that rule - true is off whatever the dates, false is on.\nOn update, null leaves it unchanged; a different value switches automation, which on the way\non runs any steps that are ready.",
            "nullable": true
          },
          "recurringTaskCode": {
            "type": "string",
            "description": "The code of the recurring task this task is associated with (optional)",
            "nullable": true
          },
          "moveWorkflowStepDates": {
            "type": "boolean",
            "description": "When the start or due date changes, whether the task's dated workflow steps move with it\n(their planned dates are worked out again from their timings). Defaults to true."
          }
        },
        "additionalProperties": false,
        "description": "Request model for updating an existing task"
      },
      "UpdateTaskSettingsRequest": {
        "type": "object",
        "properties": {
          "hideOmittedWorkflowSteps": {
            "type": "boolean",
            "description": "Whether workflow steps and step groups a condition has omitted are hidden on a task."
          }
        },
        "additionalProperties": false,
        "description": "Request to update the practice's task settings."
      },
      "UpdateTaskTemplateRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "The name of the task template"
          },
          "description": {
            "type": "string",
            "description": "The description applied to tasks created from this template",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the task, in whole minutes",
            "format": "int32",
            "nullable": true
          },
          "useWorkflowTimeEstimate": {
            "type": "boolean",
            "description": "Whether the workflow's summed step estimates stand in for TimeEstimateMinutes when a\nworkflow is applied. False keeps this estimate. Defaults to true when omitted."
          },
          "billableServiceCode": {
            "type": "string",
            "description": "Code of the billable service this template is optionally associated with",
            "nullable": true
          },
          "dueDateOffsetDays": {
            "type": "integer",
            "description": "Days after the creation date for the default task due date",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "Time of day stamped onto the start date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "dueTime": {
            "type": "string",
            "description": "Time of day stamped onto the due date of the created task. Omit for 09:00.",
            "format": "time",
            "nullable": true
          },
          "assignmentType": {
            "$ref": "#/components/schemas/AssignmentType"
          },
          "assignedUserCode": {
            "type": "string",
            "description": "Code of the user to assign tasks to (only used if AssignmentType is SpecificUser)",
            "nullable": true
          },
          "assignedTeamCode": {
            "type": "string",
            "description": "Code of the team to assign tasks to (optional, independent of AssignmentType)",
            "nullable": true
          },
          "workflowCode": {
            "type": "string",
            "description": "Code of the workflow template to apply to created tasks",
            "nullable": true
          },
          "categoryCode": {
            "type": "string",
            "description": "Code of the category to apply to created tasks",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this task template",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether this template is active (inactive templates are hidden when creating tasks)"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a one-off task template"
      },
      "UpdateTeamRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 1,
            "type": "string",
            "description": "The display name of the team"
          },
          "description": {
            "maxLength": 500,
            "type": "string",
            "description": "Optional description of the team's purpose",
            "nullable": true
          },
          "iconName": {
            "maxLength": 100,
            "type": "string",
            "description": "Optional Lucide icon name for visual identification",
            "nullable": true
          },
          "color": {
            "maxLength": 7,
            "type": "string",
            "description": "Optional hex color for visual identification",
            "nullable": true
          },
          "canBeAssignedToTasks": {
            "type": "boolean",
            "description": "Whether this team can be assigned to tasks"
          },
          "canBeAssignedToClients": {
            "type": "boolean",
            "description": "Whether this team can be assigned to clients"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating a team"
      },
      "UpdateTenantHolidayRequest": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "The date of the holiday, or its first day when it runs over several (format: yyyy-MM-dd)",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "The last day of a holiday that runs over several days (inclusive). Empty for a single day",
            "format": "date",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Name of the holiday (e.g., \"Company Anniversary\", \"Office Closure\")",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update a tenant-specific holiday"
      },
      "UpdateTenantUserRateRequest": {
        "type": "object",
        "properties": {
          "hourlyRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Charge-out rate per hour. Null gives the user no rate of their own for the period,\nso the practice default applies.",
            "format": "double",
            "nullable": true
          },
          "costRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Internal cost rate per hour. Setting a value requires the Cost Rates permission;\ncallers without it leave the stored cost rate unchanged.",
            "format": "double",
            "nullable": true
          },
          "effectiveFrom": {
            "type": "string",
            "description": "The first day the rates apply. Null means \"since forever\".",
            "format": "date",
            "nullable": true
          },
          "effectiveTo": {
            "type": "string",
            "description": "The last day the rates apply (inclusive). Null makes this the current rate — at most\none entry per user may be open.",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Full replacement of one rate entry — for correcting a historical entry's rates or dates.\nThe edited entry must not overlap the user's other entries, and at most one entry may be\nleft without an end date. Rates already stamped on logged time are never changed."
      },
      "UpdateTenantUserRequest": {
        "type": "object",
        "properties": {
          "roleType": {
            "$ref": "#/components/schemas/RoleType"
          },
          "roleCode": {
            "type": "string",
            "description": "The code of the custom role (only used if RoleType is Custom)",
            "nullable": true
          },
          "systemRoleType": {
            "$ref": "#/components/schemas/SystemRole"
          },
          "isClientManager": {
            "type": "boolean",
            "description": "Whether the user is a client manager within the tenant"
          },
          "isPartner": {
            "type": "boolean",
            "description": "Whether the user is a partner within the tenant"
          },
          "isAssociate": {
            "type": "boolean",
            "description": "Whether the user is an associate within the tenant"
          },
          "isRestrictedToTeamClients": {
            "type": "boolean",
            "description": "Whether the user can only see clients belonging to their teams"
          },
          "isRestrictedToAssignedClients": {
            "type": "boolean",
            "description": "Whether the user can only see clients where they are Manager, Partner, or Associate"
          },
          "isRestrictedToOwnTime": {
            "type": "boolean",
            "description": "Whether the user can only see and edit their own time entries"
          },
          "isPaidForTrackedTime": {
            "type": "boolean",
            "description": "Whether the practice pays this user for their tracked time (contract basis) —\nputs them on the Unpaid Time pay surfaces"
          },
          "workingPatternCode": {
            "type": "string",
            "description": "The code of the working pattern this user is on — how many hours they're expected to\nlog each day. Null puts them on the practice's default pattern.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for Updating a user within a tenant. Does not include email as it cannot be changed.\nFirstName/LastName are managed via User updates and synced to TenantUser automatically."
      },
      "UpdateTextBroadcastRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "savedViewCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The code of a saved client view whose filter selects which clients to include. The view's criteria are resolved\nwhen recipients are resolved, so later changes to the view are picked up until the text is sent. Mutually\nexclusive with Filter.",
            "nullable": true,
            "example": "active-limited-companies"
          },
          "filter": {
            "$ref": "#/components/schemas/EmailBroadcastFilterDto"
          },
          "excludedClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Client codes to exclude from the filter results",
            "nullable": true
          },
          "additionalClientCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hand-picked client codes to add on top of the filter results",
            "nullable": true
          },
          "recipientContactTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientContactType"
            },
            "description": "The client contact types texted at each client, on their mobiles. A draft needs at least one; a summary with none\nworks out only the client and preference counts.",
            "nullable": true
          },
          "sendOncePerNumber": {
            "type": "boolean",
            "description": "When true (the default), a number held by contacts at several clients is texted once, with the first client's\ntokens; the other clients are skipped",
            "example": true
          },
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "What the bulk text is called in the list, the client notes and Messages",
            "example": "January self assessment reminder"
          },
          "routing": {
            "$ref": "#/components/schemas/MessagingRequestTextRouting"
          },
          "templateCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The practice text template whose body is the SMS text. Mutually exclusive with Body.",
            "nullable": true,
            "example": "self-assessment-reminder"
          },
          "body": {
            "maxLength": 1600,
            "type": "string",
            "description": "The SMS text with Liquid tokens ({{ Client.Name }}, {{ Contact.FirstName }}, {{ Practice.Name }}, {{ Url }} …),\nrendered for each client and recipient. Mutually exclusive with TemplateCode.",
            "nullable": true,
            "example": "Hi {{ Contact.FirstName }}, your tax return for {{ Client.Name }} is due on 31 January."
          },
          "whatsAppTemplateId": {
            "type": "string",
            "description": "The approved WhatsApp template sent where the routing chooses WhatsApp: required with KnownNumbers or\nTryWhatsAppFirst, and must be omitted with SmsOnly. Refused when it has no approved live version.",
            "format": "uuid",
            "nullable": true
          },
          "contentVariables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "What fills each of the WhatsApp template's placeholders, by placeholder (\"1\", \"2\"…): a token expression such as\n{{ Contact.FirstName }}, rendered per recipient. Every placeholder of the template's approved version must be\nfilled, and no other. Must be omitted with SmsOnly routing.",
            "nullable": true,
            "example": {
              "1": "{{ Contact.FirstName }}",
              "2": "{{ Client.Name }}"
            }
          }
        },
        "additionalProperties": false,
        "description": "Request to update a draft bulk text. PUT is a full replacement: all fields are applied as provided.\nOnly a Draft can be updated. Same shape as the create request."
      },
      "UpdateThirdPartyConnectionRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name for the connection",
            "nullable": true
          },
          "redirectUrl": {
            "type": "string",
            "description": "URL to redirect the user to after OAuth flow completes. \nIf you use [code] in the url then we'll replace it with the Code of this ThirdPartyConnection.\nThis solves the problem of not knowing the code at creation time.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request for updating an existing ThirdPartyConnection"
      },
      "UpdateTimeEntryRequest": {
        "required": [
          "entryDate",
          "userCode"
        ],
        "type": "object",
        "properties": {
          "userCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the team member who did the work"
          },
          "entryDate": {
            "type": "string",
            "description": "The day the work was done (format: yyyy-MM-dd)",
            "format": "date"
          },
          "durationMinutes": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "How long the work took, in minutes",
            "format": "int32"
          },
          "startTime": {
            "type": "string",
            "description": "When the work started (UTC) — optional, set by timer-logged entries",
            "format": "date-time",
            "nullable": true
          },
          "endTime": {
            "type": "string",
            "description": "When the work ended (UTC) — optional, set by timer-logged entries",
            "format": "date-time",
            "nullable": true
          },
          "description": {
            "maxLength": 1000,
            "type": "string",
            "description": "What the time was spent on",
            "nullable": true
          },
          "clientCode": {
            "type": "string",
            "description": "The code of the client the time relates to (optional unless the practice requires linking)",
            "nullable": true
          },
          "taskItemCode": {
            "type": "string",
            "description": "The code of the task the time relates to (optional unless the practice requires linking)",
            "nullable": true
          },
          "serviceCode": {
            "type": "string",
            "description": "The code of the client service to attribute the time to directly, instead of\nvia a task. Requires ClientCode (service codes are client-scoped) and cannot\nbe combined with TaskItemCode — a task already determines the service.\nOmit to unlink the service.",
            "nullable": true
          },
          "stageCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The service stage the time was logged in, among the stages of the entry's service. Left out on a\ncreate, it defaults to the stage the task last moved its service to, else the service's current stage;\nleft out on an update, the entry keeps its stage (an empty string clears it)",
            "nullable": true
          },
          "workflowGroupNumber": {
            "type": "integer",
            "description": "The group number of the workflow step the time relates to (optional; requires\nTaskItemCode and WorkflowStepNumber). Omit both numbers to unlink the step.",
            "format": "int32",
            "nullable": true
          },
          "workflowStepNumber": {
            "type": "integer",
            "description": "The step number of the workflow step the time relates to (optional; requires\nTaskItemCode and WorkflowGroupNumber). Omit both numbers to unlink the step.",
            "format": "int32",
            "nullable": true
          },
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimerBlockDto"
            },
            "description": "The edited work blocks, for block-sourced entries. When provided, StartTime,\nEndTime and DurationMinutes are derived from the blocks and any supplied\nvalues are ignored; when omitted the entry's existing blocks are kept.\nEach block needs either a start and end time or a duration in minutes.",
            "nullable": true
          },
          "isBillable": {
            "type": "boolean",
            "description": "Whether this time can be billed to the client"
          },
          "hourlyRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Charge-out rate per hour. When omitted on a billable entry, defaults to the rate in force on the\nentry date. When omitted on a non-billable entry, the entry keeps its rate, unless its team member,\ndate or work changed, when it defaults likewise (ClientJobBudgets R4).",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to update a time entry (full replacement)"
      },
      "UpdateTimeRecordingSettingsRequest": {
        "type": "object",
        "properties": {
          "timeTrackingEnabled": {
            "type": "boolean",
            "description": "Whether time tracking is enabled for this tenant"
          },
          "requireClientOrTask": {
            "type": "boolean",
            "description": "When true, every time entry must be linked to a client or a task"
          },
          "billableByDefault": {
            "type": "boolean",
            "description": "When true, new time entries and timers start as billable"
          },
          "defaultHourlyRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Default charge-out rate per hour for billable time entries,\nused when the team member has no rate of their own",
            "format": "double",
            "nullable": true
          },
          "defaultCostRate": {
            "maximum": 100000,
            "minimum": 0,
            "type": "number",
            "description": "Default cost rate per hour, used when the team member has no cost rate of their own.\nSetting it requires the Cost Rates update permission",
            "format": "double",
            "nullable": true
          },
          "billingLineMode": {
            "$ref": "#/components/schemas/TimeBillingLineMode"
          },
          "autoTimerEnabled": {
            "type": "boolean",
            "description": "When true, starting a workflow step (or a task with no workflow) starts a timer\nfor the acting user linked to it, and completing or skipping it stops the linked\ntimer and logs the time"
          },
          "workTypeRatePrecedence": {
            "$ref": "#/components/schemas/WorkTypeRatePrecedence"
          },
          "budgetWarningPercent": {
            "maximum": 100,
            "minimum": 1,
            "type": "integer",
            "description": "The share of a job budget, in percent, at which its time is shown as near the line and the\nmanager is warned (docs/features/ClientJobBudgets/PLAN.md D7)",
            "format": "int32"
          },
          "budgetsEnabled": {
            "type": "boolean",
            "description": "Whether the practice uses job budgets. Off by default: budget progress, the Budgets report, budget\nalerts and Cost & Profit's price and fee budget are hidden. Switching it off keeps every standard\nand client figure, so switching it back on restores them."
          },
          "showBudgetOnTasks": {
            "type": "boolean",
            "description": "Whether a task's page shows the Budget card while budgets are on. On by default; off only hides\nthe card (the task budget route still answers), so the practice can keep budgets to services,\nclients and reports."
          },
          "feeBudgetsEnabled": {
            "type": "boolean",
            "description": "Whether the practice uses fee budgets beside hours (ClientJobBudgets R3). Off by default; off means\nnothing about money anywhere: no fee figures, fee columns, fee alerts or value of time, and the fee\nroutes refuse. Every fee figure is kept, so switching it back on restores them. The Fee Budgets\npermission still decides who sees them while on."
          }
        },
        "additionalProperties": false,
        "description": "Request to update time recording settings for the tenant"
      },
      "UpdateUserNoteRequest": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "The note content. Send an empty string to clear the note.",
            "nullable": true
          },
          "isRichText": {
            "type": "boolean",
            "description": "Whether SodiumHQ.DTOs.UserNote.UpdateUserNoteRequest.Text is HTML from the rich-text editor rather than plain text"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for saving one of the caller's own notes"
      },
      "UpdateUserProfileRequest": {
        "type": "object",
        "properties": {
          "firstName": {
            "type": "string",
            "description": "The user's first name",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "description": "The user's last name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating user profile information (name only)"
      },
      "UpdateWorkflowRequest": {
        "required": [
          "groups",
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The name of the workflow"
          },
          "description": {
            "type": "string",
            "description": "Optional description explaining the workflow's purpose",
            "nullable": true
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowGroupDto"
            },
            "description": "The workflow groups containing steps"
          }
        },
        "additionalProperties": false,
        "description": "Request to update an existing workflow"
      },
      "UpdateWorkflowStepRequest": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "blockedReason": {
            "maxLength": 500,
            "type": "string",
            "description": "The reason the step is blocked (optional). Only used when setting status to \"Blocked\".",
            "nullable": true
          },
          "assignedUserCode": {
            "maxLength": 50,
            "type": "string",
            "description": "The user code to assign this step to (optional).\nMust be a valid user code for an active user in the tenant.\nIf null, the assignment will not be changed.",
            "nullable": true
          },
          "assignedTeamCode": {
            "maxLength": 100,
            "type": "string",
            "description": "The team code to assign this step to (optional, independent of user assignment).\nIf null, the team assignment will not be changed.",
            "nullable": true
          },
          "emailStepConfiguration": {
            "$ref": "#/components/schemas/EmailStepConfigDto"
          },
          "documentRequestStepConfiguration": {
            "$ref": "#/components/schemas/DocumentRequestStepConfigDto"
          },
          "clientConfirmationStepConfiguration": {
            "$ref": "#/components/schemas/ClientConfirmationStepConfigDto"
          },
          "textMessageStepConfiguration": {
            "$ref": "#/components/schemas/SendTextMessageStepConfigDto"
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this workflow step. Replaces all existing checklist items when provided.",
            "nullable": true
          },
          "hasUpdates": {
            "type": "boolean",
            "description": "Validates that at least one property is being updated",
            "readOnly": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for updating workflow step properties.\nSupports updating status, assignment, and step-type configuration.\nAt least one property must be provided.\n            \nAPI Usage:\n- PUT /api/tenants/{tenant}/tasks/{taskCode}/workflow/steps/{stepId}\n- Supports updating multiple fields at once or individual fields\n- Validates that changes are appropriate and permissions are met\n            \nExample Usage:\n```\nPUT /api/tenants/acme/tasks/TASK-001/workflow/steps/123\n{\n    \"status\": \"Completed\",\n    \"assignedUserCode\": \"john.doe\"\n}\n```"
      },
      "UpdateWorkingDaySettingsRequest": {
        "type": "object",
        "properties": {
          "defaultHolidayAdjustment": {
            "$ref": "#/components/schemas/HolidayAdjustment"
          },
          "bankHolidayRegion": {
            "$ref": "#/components/schemas/BankHolidayRegion"
          }
        },
        "additionalProperties": false,
        "description": "Request to update working day settings for the tenant"
      },
      "UpdateWorkingPatternRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name of the pattern, e.g. \"Full time\" or \"Part time (Mon/Wed/Fri)\""
          },
          "isDefault": {
            "type": "boolean",
            "description": "Make this the tenant's default pattern, clearing the flag from the previous default"
          },
          "expectedMinutesMonday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Monday (7.5 hours = 450)",
            "format": "int32"
          },
          "expectedMinutesTuesday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Tuesday",
            "format": "int32"
          },
          "expectedMinutesWednesday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Wednesday",
            "format": "int32"
          },
          "expectedMinutesThursday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Thursday",
            "format": "int32"
          },
          "expectedMinutesFriday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Friday",
            "format": "int32"
          },
          "expectedMinutesSaturday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Saturday",
            "format": "int32"
          },
          "expectedMinutesSunday": {
            "maximum": 1440,
            "minimum": 0,
            "type": "integer",
            "description": "Minutes expected on a Sunday",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Request to update a working pattern. A full replacement — every day is applied as sent,\nso omitting one sets it to no expected time."
      },
      "UpdateWriteOffReasonRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 1,
            "type": "string",
            "description": "The display name"
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position in the reason picker",
            "format": "int32"
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the reason is offered for new write-offs"
          }
        },
        "additionalProperties": false,
        "description": "Request to update a write-off reason. Deactivate a reason rather than deleting it once it\nhas been used: it stays on the allocations that carry it."
      },
      "UploadEngagementPdfRequest": {
        "required": [
          "pdfContent"
        ],
        "type": "object",
        "properties": {
          "pdfContent": {
            "minLength": 1,
            "type": "string",
            "description": "Base64-encoded PDF content.\nExample: \"JVBERi0xLjQKJeLjz9MNCjEgMCBvYmoKPDwKL1R5cGUgL0NhdGFsb2cK...\""
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for uploading PDF documents to an engagement"
      },
      "UpsertBaseFolderRequest": {
        "required": [
          "containerId",
          "displayPath"
        ],
        "type": "object",
        "properties": {
          "containerId": {
            "minLength": 1,
            "type": "string",
            "description": "Provider-specific identifier for the folder/container.\n- Google Drive: The folder ID"
          },
          "driveId": {
            "type": "string",
            "description": "Provider-specific drive identifier. Null when not applicable.\n- Google Drive: The Shared Drive ID if using a Shared Drive; null for \"My Drive\"",
            "nullable": true
          },
          "siteId": {
            "type": "string",
            "description": "Provider-specific site identifier. Null when not applicable.\n- Google Drive: Not used",
            "nullable": true
          },
          "displayPath": {
            "minLength": 1,
            "type": "string",
            "description": "Human-readable path for display in the UI only.\ne.g., \"My Drive/Sodium/Clients\""
          },
          "externalUrl": {
            "type": "string",
            "description": "URL to open this folder in the provider's web UI",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for upserting the base folder for a connection"
      },
      "UpsertServiceMappingRequest": {
        "required": [
          "externalServiceId"
        ],
        "type": "object",
        "properties": {
          "externalServiceId": {
            "minLength": 1,
            "type": "string",
            "description": "The external platform's service template ID (e.g., Socket's availableProposalLineId)"
          },
          "externalServiceName": {
            "type": "string",
            "description": "The display name of the service on the external platform (cached for display)",
            "nullable": true
          },
          "billableServiceCode": {
            "type": "string",
            "description": "The Sodium BillableService code to map to. Required unless IsIgnored is true.",
            "nullable": true
          },
          "isIgnored": {
            "type": "boolean",
            "description": "True to ignore this external service: no Sodium service is created for it, now or on later proposals"
          }
        },
        "additionalProperties": false,
        "description": "Request to map an external service template to a Sodium BillableService, or to ignore it"
      },
      "UpsertUserViewPreferenceRequest": {
        "required": [
          "configJson"
        ],
        "type": "object",
        "properties": {
          "configJson": {
            "minLength": 1,
            "type": "string",
            "description": "The JSON configuration for this view"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for creating or updating a user's view preference"
      },
      "UserBillingSummaryDto": {
        "type": "object",
        "properties": {
          "includedUserCount": {
            "type": "integer",
            "description": "Number of users included in the subscription at no extra charge",
            "format": "int32"
          },
          "additionalUserPricePence": {
            "type": "integer",
            "description": "Monthly price in pence for each user above IncludedUserCount. 0 = overage billing disabled.",
            "format": "int32"
          },
          "billableUserCount": {
            "type": "integer",
            "description": "Current number of users counting towards the allowance (Active and Invited)",
            "format": "int32"
          },
          "additionalUserCount": {
            "type": "integer",
            "description": "Number of users above the included allowance (0 when within the allowance)",
            "format": "int32"
          },
          "estimatedMonthlyChargePence": {
            "type": "integer",
            "description": "Estimated monthly charge in pence for the additional users\n(AdditionalUserCount x AdditionalUserPricePence)",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Summary of the tenant's per-user billing position: how many users are included\nin their subscription, how many they have, and what any additional users cost."
      },
      "UserNoteDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier within the tenant",
            "nullable": true
          },
          "text": {
            "type": "string",
            "description": "The note content",
            "nullable": true
          },
          "isRichText": {
            "type": "boolean",
            "description": "Whether SodiumHQ.DTOs.UserNote.UserNoteDto.Text is HTML from the rich-text editor rather than plain text"
          },
          "createdDate": {
            "type": "string",
            "description": "When the note was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the note was last saved; null when it has not been changed since creation",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for one of the caller's own notes"
      },
      "UserProfileResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The user's unique code",
            "nullable": true
          },
          "email": {
            "type": "string",
            "description": "The user's email address",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "description": "The user's first name",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "description": "The user's last name",
            "nullable": true
          },
          "fullName": {
            "type": "string",
            "description": "The user's full name",
            "nullable": true
          },
          "avatar": {
            "type": "string",
            "description": "URL to the user's avatar image",
            "nullable": true
          },
          "utm": {
            "$ref": "#/components/schemas/UtmInfoDto"
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for user profile information"
      },
      "UserViewPreferenceDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique identifier within the tenant",
            "nullable": true
          },
          "viewKey": {
            "type": "string",
            "description": "The view this preference applies to (e.g. \"dashboard\")",
            "nullable": true
          },
          "configJson": {
            "type": "string",
            "description": "The JSON configuration for this view",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "description": "When the preference was created",
            "format": "date-time"
          },
          "updatedDate": {
            "type": "string",
            "description": "When the preference was last updated",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for a user's view preference configuration"
      },
      "UtmInfoDto": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "nullable": true
          },
          "medium": {
            "type": "string",
            "nullable": true
          },
          "term": {
            "type": "string",
            "nullable": true
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "campaign": {
            "type": "string",
            "nullable": true
          },
          "referer": {
            "type": "string",
            "nullable": true
          },
          "firstSource": {
            "type": "string",
            "description": "utm_source of the first campaign link that brought the user to the site. The fields above are the last one, which a\nlater campaign link overwrites.",
            "nullable": true
          },
          "firstContent": {
            "type": "string",
            "description": "utm_content of the first campaign link that brought the user to the site.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO containing UTM tracking information"
      },
      "ValidateTemplateRequest": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "type": "string",
            "description": "The raw template content to validate. May contain Liquid syntax and editor chip markup."
          }
        },
        "additionalProperties": false,
        "description": "Request to validate a Liquid template fragment (email body, subject, content block, etc.)\nwithout rendering it. Used by editors to block saving syntactically broken templates."
      },
      "ValidationProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "VatDetailsDto": {
        "type": "object",
        "properties": {
          "registered": {
            "type": "boolean",
            "description": "Indicates whether the business is registered for VAT"
          },
          "number": {
            "maxLength": 20,
            "type": "string",
            "description": "VAT registration number",
            "nullable": true
          },
          "registrationDate": {
            "type": "string",
            "description": "Date when the business registered for VAT",
            "format": "date-time",
            "nullable": true
          },
          "scheme": {
            "$ref": "#/components/schemas/VatScheme"
          },
          "reportingPeriod": {
            "$ref": "#/components/schemas/VatReportingPeriod"
          },
          "verified": {
            "type": "boolean",
            "description": "Whether the VAT number has been verified against HMRC. Read-only: set by the verification\nendpoint, and cleared automatically whenever the VAT number changes — values sent on an\nupdate are ignored."
          },
          "verifiedDate": {
            "type": "string",
            "description": "When the VAT number was last verified with HMRC. Read-only.",
            "format": "date-time",
            "nullable": true
          },
          "verifiedName": {
            "type": "string",
            "description": "The name HMRC holds the registration under, captured at verification. Read-only.",
            "nullable": true
          },
          "consultationNumber": {
            "type": "string",
            "description": "HMRC's consultation number for a verified check — proof the check was made. Present only\nwhen the practice's own VAT number was on record at verification time. Read-only.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "VAT registration and scheme details for a business"
      },
      "VatNumberVerificationDto": {
        "type": "object",
        "properties": {
          "registered": {
            "type": "boolean",
            "description": "Whether HMRC recognises the number as a current VAT registration."
          },
          "vatNumber": {
            "type": "string",
            "description": "The VAT number that was checked, as normalised by HMRC (no GB prefix, no spaces).",
            "nullable": true
          },
          "hmrcName": {
            "type": "string",
            "description": "The name HMRC holds the registration under. Null when not registered.",
            "nullable": true
          },
          "hmrcAddressLine1": {
            "type": "string",
            "description": "First line of the registered address. Null when not registered.",
            "nullable": true
          },
          "hmrcPostcode": {
            "type": "string",
            "description": "Postcode of the registered address. Null when not registered or held abroad.",
            "nullable": true
          },
          "hmrcCountryCode": {
            "type": "string",
            "description": "ISO country code of the registered address. Null when not registered.",
            "nullable": true
          },
          "consultationNumber": {
            "type": "string",
            "description": "HMRC's consultation number — proof the check was made, for the AML file. Present only when\nthe practice's own VAT number is on record (which upgrades the check to a verified one).",
            "nullable": true
          },
          "verifiedDate": {
            "type": "string",
            "description": "When the verification was recorded. Null when the number was not registered.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The outcome of verifying a client's VAT number against HMRC's Check a UK VAT Number service.\nWhen the number is registered, HMRC's registered name and address are returned so the user can\ncompare them with the client record — a mismatch is information, not an error."
      },
      "VatPeriodTokens": {
        "type": "object",
        "properties": {
          "period": {
            "type": "string",
            "description": "Human label for the period (e.g. \"May 2026\" or \"Apr-Jun 2026\").",
            "nullable": true
          },
          "periodStart": {
            "type": "string",
            "description": "First day of the VAT return period being filed.",
            "format": "date",
            "nullable": true
          },
          "periodEnd": {
            "type": "string",
            "description": "Last day of the VAT return period being filed.",
            "format": "date",
            "nullable": true
          },
          "submissionDeadline": {
            "type": "string",
            "description": "HMRC submission deadline - one calendar month and seven days after the period end.",
            "format": "date",
            "nullable": true
          },
          "previous": {
            "$ref": "#/components/schemas/VatPeriodTokens"
          },
          "next": {
            "$ref": "#/components/schemas/VatPeriodTokens"
          }
        },
        "additionalProperties": false,
        "description": "Computed VAT period tokens for the return the client is currently filing - the most recently\nclosed period whose submission deadline has not yet passed (falling through to the open period\nonce that deadline is behind us). Anchored on a supplied reference date, so an email generated\nfrom a task can resolve the return the task is for, independent of when the email is sent.\nUsage: {{ Vat.Period }}, {{ Vat.PeriodStart | formatDate: \"dd MMM yyyy\" }}, {{ Vat.SubmissionDeadline | formatDate: \"dd MMM yyyy\" }}.\nEmpty when the client is not VAT-registered, has no reporting period, or is on the Annual scheme."
      },
      "VatRate": {
        "enum": [
          "Standard",
          "Reduced",
          "Zero",
          "Exempt",
          "OutOfScope",
          "UaeStandard"
        ],
        "type": "string",
        "example": "Standard"
      },
      "VatRegime": {
        "enum": [
          "Uk",
          "Uae"
        ],
        "type": "string",
        "example": "Uk"
      },
      "VatReportingPeriod": {
        "enum": [
          "Monthly",
          "QuarterlyJanAprJulOct",
          "QuarterlyFebMayAugNov",
          "QuarterlyMarJunSepDec",
          "Annual"
        ],
        "type": "string",
        "example": "Monthly"
      },
      "VatScheme": {
        "enum": [
          "Standard",
          "FlatRate",
          "CashAccounting",
          "AnnualAccounting",
          "MarginScheme",
          "PartialExemption",
          "RetailSchemes",
          "TourOperatorsMarginScheme",
          "AgriculturalFlatRate",
          "OneStopShop"
        ],
        "type": "string",
        "example": "Standard"
      },
      "VatTreatment": {
        "enum": [
          "Standard",
          "ReverseCharge",
          "OutsideScope"
        ],
        "type": "string",
        "description": "How VAT applies to a billing account's invoices.",
        "example": "Standard"
      },
      "VerificationResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the operation was successful"
          },
          "message": {
            "type": "string",
            "description": "Message describing the result",
            "nullable": true
          },
          "errorCode": {
            "type": "string",
            "description": "Error code for client handling (if failed)",
            "nullable": true
          },
          "userCode": {
            "type": "string",
            "description": "User code (if applicable)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response DTO for email verification operations"
      },
      "VerifyEmailRequest": {
        "required": [
          "verificationKey"
        ],
        "type": "object",
        "properties": {
          "verificationKey": {
            "type": "string",
            "description": "The verification key from the email link",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "Request DTO for email verification"
      },
      "VerifyMtdAuthorisationRequest": {
        "type": "object",
        "properties": {
          "authorisationType": {
            "$ref": "#/components/schemas/AgentAuthorisationType"
          }
        },
        "additionalProperties": false,
        "description": "Request to verify one client's MTD authorisation against HMRC."
      },
      "WeekDayPatternDto": {
        "type": "object",
        "properties": {
          "position": {
            "$ref": "#/components/schemas/MonthDayType"
          },
          "day": {
            "$ref": "#/components/schemas/WeekDayType"
          }
        },
        "additionalProperties": false,
        "description": "DTO for positional weekday patterns in recurring tasks.\nExample: { Position: \"First\", Day: \"Monday\" } for \"First Monday of the month\""
      },
      "WeekDayType": {
        "enum": [
          "Workday",
          "Monday",
          "Tuesday",
          "Wednesday",
          "Thursday",
          "Friday",
          "Saturday",
          "Sunday"
        ],
        "type": "string",
        "example": "Workday"
      },
      "WipAgeingReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/WipAgeingSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/WipAgeingRowDtoPagedResult"
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC).",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The WIP / Ageing report: a point-in-time snapshot of open work - what's sitting untouched,\nhow old it is, and where it's stuck."
      },
      "WipAgeingRowDto": {
        "type": "object",
        "properties": {
          "groupKind": {
            "$ref": "#/components/schemas/ReportGroupKind"
          },
          "groupCode": {
            "type": "string",
            "description": "Entity code, bucket key (\"0-7\"), status name, or current step name. Null for null buckets.",
            "nullable": true
          },
          "groupName": {
            "type": "string",
            "description": "Display name for the group.",
            "nullable": true
          },
          "currentStepType": {
            "$ref": "#/components/schemas/WorkflowStepType"
          },
          "count": {
            "type": "integer",
            "description": "Open tasks in this group.",
            "format": "int32"
          },
          "avgAgeDays": {
            "type": "number",
            "description": "Average age in days (planned start to today).",
            "format": "double"
          },
          "oldestAgeDays": {
            "type": "integer",
            "description": "Age of this group's oldest task in days.",
            "format": "int32"
          },
          "oldestTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "blockedCount": {
            "type": "integer",
            "description": "How many of this group's tasks are currently blocked.",
            "format": "int32"
          },
          "overdueCount": {
            "type": "integer",
            "description": "How many of this group's tasks are past their due date.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One row of the WIP / Ageing breakdown table."
      },
      "WipAgeingRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WipAgeingRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "WipAgeingSummaryDto": {
        "type": "object",
        "properties": {
          "openCount": {
            "type": "integer",
            "description": "Open tasks whose planned start date has arrived.",
            "format": "int32"
          },
          "notStartedCount": {
            "type": "integer",
            "description": "Cohort tasks not yet started - work that should have begun but hasn't been touched.",
            "format": "int32"
          },
          "blockedCount": {
            "type": "integer",
            "description": "Cohort tasks currently blocked.",
            "format": "int32"
          },
          "overdueCount": {
            "type": "integer",
            "description": "Cohort tasks past their due date.",
            "format": "int32"
          },
          "avgAgeDays": {
            "type": "number",
            "description": "Average age in days (planned start to today). Null when the cohort is empty.",
            "format": "double",
            "nullable": true
          },
          "oldestAgeDays": {
            "type": "integer",
            "description": "Age of the oldest open task in days. Null when the cohort is empty.",
            "format": "int32",
            "nullable": true
          },
          "oldestTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          }
        },
        "additionalProperties": false,
        "description": "Headline KPIs for the WIP / Ageing report."
      },
      "WipRemainderHandling": {
        "enum": [
          "LeaveOpen",
          "WriteOff"
        ],
        "type": "string",
        "example": "LeaveOpen"
      },
      "WorkTypeRateDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this rate entry",
            "nullable": true
          },
          "tenantUserCode": {
            "type": "string",
            "description": "The team member the rate is for. Null for a practice-level rate.",
            "nullable": true
          },
          "taskCategoryCode": {
            "type": "string",
            "description": "The task category priced. Exactly one of taskCategoryCode and billableServiceCode is set.",
            "nullable": true
          },
          "taskCategoryName": {
            "type": "string",
            "description": "The task category's name",
            "nullable": true
          },
          "billableServiceCode": {
            "type": "string",
            "description": "The library service priced. Exactly one of taskCategoryCode and billableServiceCode is set.",
            "nullable": true
          },
          "billableServiceName": {
            "type": "string",
            "description": "The library service's name",
            "nullable": true
          },
          "hourlyRate": {
            "type": "number",
            "description": "Charge-out rate per hour. Null leaves the charge-out rate to the next rule down.",
            "format": "double",
            "nullable": true
          },
          "costRate": {
            "type": "number",
            "description": "Internal cost rate per hour. Null when not set (the next rule down applies), or when the\ncaller lacks the Cost Rates permission.",
            "format": "double",
            "nullable": true
          },
          "effectiveFrom": {
            "type": "string",
            "description": "The first day the rates apply. Null means \"since forever\".",
            "format": "date",
            "nullable": true
          },
          "effectiveTo": {
            "type": "string",
            "description": "The last day the rates apply (inclusive). Null marks the current rate.",
            "format": "date",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A date-effective rate for a type of work — a task category or a library service — for one\nteam member or, with no team member, the whole practice. Each (team member or practice,\ntype of work) has at most one open entry (null effectiveTo — the current rate), and its\nentries never overlap."
      },
      "WorkTypeRatePrecedence": {
        "enum": [
          "TaskCategory",
          "Service"
        ],
        "type": "string",
        "example": "TaskCategory"
      },
      "WorkflowDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable identifier. For library-shipped items this is the library code; for tenant-imported\nitems this is the tenant entity's own code.",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "Display name shown to users in lists, dialogs, and the import browser.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Optional human-readable summary of what this entity is for.",
            "nullable": true
          },
          "libraryCode": {
            "type": "string",
            "description": "The Code of the library template this entity was imported from, or null if the entity\nis not from the library. Read-only — cannot be changed once set. Example: \"vat_returns\".",
            "nullable": true
          },
          "libraryStatus": {
            "$ref": "#/components/schemas/LibraryStatus"
          },
          "isImported": {
            "type": "boolean",
            "description": "True if the tenant has already imported this library item."
          },
          "deprecated": {
            "type": "boolean",
            "description": "True if this library item has been retired. Deprecated items are hidden from the import\nbrowser (so new tasks cannot be created from them) but remain available for revert-to-library\non existing imports."
          },
          "groupCount": {
            "type": "integer",
            "description": "Total number of groups in this workflow",
            "format": "int32"
          },
          "stepCount": {
            "type": "integer",
            "description": "Total number of steps across all groups in this workflow",
            "format": "int32"
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowGroupDto"
            },
            "description": "The workflow groups containing steps",
            "nullable": true
          },
          "hasAutoExecutingStepsWithNoDependencies": {
            "type": "boolean",
            "description": "Whether this workflow contains any auto-executing steps with no dependencies.\nThese steps will execute automatically when the workflow is applied to a task."
          },
          "requiresClient": {
            "type": "boolean",
            "description": "Whether this workflow requires a client to be associated with the task.\nTrue if any email step uses client tokens in content or sends to client contact recipients."
          }
        },
        "additionalProperties": false,
        "description": "DTO for workflow templates, exposing only codes and structured data (never DB IDs)."
      },
      "WorkflowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "WorkflowEmailSenderSource": {
        "enum": [
          "PracticeDefault",
          "TaskAssignee",
          "StepAssignee",
          "ClientManager",
          "ClientServiceManager",
          "ClientPartner",
          "ClientAssociate",
          "SpecificMailbox",
          "ClientServicePreparer",
          "ClientServiceReviewer"
        ],
        "type": "string",
        "example": "PracticeDefault"
      },
      "WorkflowGroupDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the workflow group",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The description of the workflow group",
            "nullable": true
          },
          "deadlineIntervalValue": {
            "type": "integer",
            "description": "The deadline interval, in DeadlineIntervalUnits. Zero or positive: counted back from the task's\ndue date, or forward from its start date, as DeadlineRelativeTo says. Zero is that date itself.\n            \nExample: Tax Return Workflow, all counted back from the due date\n- \"Data Collection\" group: 14 days\n- \"Preparation\" group: 7 days\n- \"Review\" group: 1 day\n- \"Filing\" group: 0 days (the due date itself)",
            "format": "int32"
          },
          "deadlineIntervalUnit": {
            "$ref": "#/components/schemas/RecurrenceUnit"
          },
          "deadlineRelativeTo": {
            "$ref": "#/components/schemas/DeadlineReferenceType"
          },
          "groupNumber": {
            "type": "integer",
            "description": "The group number that determines the display order and sequencing of this group within the workflow.\nGroups are displayed in ascending order by this number (1, 2, 3, etc.).",
            "format": "int32"
          },
          "dependsOnPreviousGroup": {
            "type": "boolean",
            "description": "Whether every step in this group waits for all steps in the previous group to be\ncompleted or skipped before it can start. Not applicable to the first group."
          },
          "condition": {
            "$ref": "#/components/schemas/ConditionDto"
          },
          "clientTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "The types of clients this group is applicable to.\nAn empty list means the group applies to all client types.",
            "nullable": true
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepDto"
            },
            "description": "The workflow steps contained within this group.\nAll steps inherit the group's calculated deadline for planning and prioritization.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for workflow groups within a workflow.\n            \nWorkflow Group Deadlines:\nEach group's deadline is DeadlineIntervalValue DeadlineIntervalUnits counted from the task's due date\n(before it) or its start date (after it), as the group's DeadlineRelativeTo says. Groups in one\nworkflow can count from different dates.\n            \nAll workflow steps within a group inherit the group's calculated deadline."
      },
      "WorkflowGroupProgressDto": {
        "type": "object",
        "properties": {
          "groupNumber": {
            "type": "integer",
            "description": "Sequential group number within the task (1, 2, 3, etc.).\nUsed for referencing the group in API calls and ordering display.",
            "format": "int32"
          },
          "groupName": {
            "type": "string",
            "description": "The name of the workflow group.\nUsed for section headers and group organization.",
            "nullable": true
          },
          "groupDescription": {
            "type": "string",
            "description": "The description of the workflow group.\nProvides context for the group's purpose.",
            "nullable": true
          },
          "dependsOnPreviousGroup": {
            "type": "boolean",
            "description": "Whether every step in this group waits for all steps in the previous group to be\ncompleted or skipped before it can start."
          },
          "groupDeadline": {
            "type": "string",
            "description": "The calculated deadline for this workflow group.\nThis is computed as TaskItem.DueDate + (DeadlineIntervalValue * DeadlineIntervalUnit)\nwhen the workflow is assigned to a task.\n            \nExample: If task is due March 15th and group has DeadlineIntervalValue = -3, DeadlineIntervalUnit = Day,\nthen GroupDeadline would be March 12th (3 days before task deadline).\n            \nThis deadline applies to all steps within this group.",
            "format": "date-time",
            "nullable": true
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepProgressDto"
            },
            "description": "The workflow steps belonging to this group.\nOrdered by step number for consistent display.",
            "nullable": true
          },
          "totalSteps": {
            "type": "integer",
            "description": "The number of steps in this group.\nUsed for group-level progress calculations.",
            "format": "int32"
          },
          "completedSteps": {
            "type": "integer",
            "description": "The number of completed steps in this group.\nUsed for group-level progress visualization.",
            "format": "int32"
          },
          "groupProgressPercentage": {
            "type": "number",
            "description": "The percentage of completion for this group (0-100).\nCalculated as (CompletedSteps / TotalSteps) * 100.\nUsed for group-level progress bars.",
            "format": "double"
          },
          "isOmitted": {
            "type": "boolean",
            "description": "Whether this group is omitted because its visibility condition is not met by the\ntask's primary client (set only when every step in the group is omitted)."
          },
          "omittedReason": {
            "type": "string",
            "description": "Human-readable explanation of why this group is omitted. Null when not omitted.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents a workflow group with its associated step progress.\nUsed for organizing workflow steps into logical groups for display.\n            \nAPI Usage:\n- Part of TaskWorkflowProgressDto for grouped step display\n- Helps organize large workflows into manageable sections\n- Provides group-level progress statistics and deadline information"
      },
      "WorkflowOccurrenceDto": {
        "type": "object",
        "properties": {
          "task": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "client": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "completedDate": {
            "type": "string",
            "description": "When the task completed (UTC).",
            "format": "date-time"
          },
          "totalElapsedDays": {
            "type": "number",
            "description": "Days from the task's actual start (fallback planned start) to completion.",
            "format": "double"
          },
          "clientWaitDays": {
            "type": "number",
            "description": "Days of the step chain spent waiting on the client.",
            "format": "double"
          },
          "internalDays": {
            "type": "number",
            "description": "Days of the step chain spent on practice-side steps.",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "One occurrence (task) of the workflow: its total elapsed time and the client-wait vs\ninternal split - \"show me the ten slowest VAT-return runs this quarter\"."
      },
      "WorkflowOccurrenceDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowOccurrenceDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "WorkflowSortField": {
        "enum": [
          "Name",
          "GroupCount",
          "StepCount",
          "UpdatedDate"
        ],
        "type": "string",
        "example": "Name"
      },
      "WorkflowStepAnalysisReportDto": {
        "type": "object",
        "properties": {
          "workflow": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "summary": {
            "$ref": "#/components/schemas/WorkflowStepAnalysisSummaryDto"
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepAnalysisStepDto"
            },
            "description": "Per-step duration distributions, in workflow order. The occurrence list is served\nseparately (paged) by the occurrences endpoint.",
            "nullable": true
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC).",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Workflow Step Analysis report: for one workflow template, where does the time go across\nevery occurrence (task) spawned from it - per-step duration distributions plus a worst-first\noccurrence list. Distributions over few occurrences are noise, so check the occurrence count."
      },
      "WorkflowStepAnalysisStepDto": {
        "type": "object",
        "properties": {
          "groupName": {
            "type": "string",
            "description": "The workflow group (section) the step belongs to - lets the UI divide the step table\ninto the same sections the workflow shows.",
            "nullable": true
          },
          "stepName": {
            "type": "string",
            "description": "The step name as snapshotted onto the tasks.",
            "nullable": true
          },
          "stepType": {
            "$ref": "#/components/schemas/WorkflowStepType"
          },
          "stage": {
            "$ref": "#/components/schemas/ClientBillableServiceStageDto"
          },
          "isClientWait": {
            "type": "boolean",
            "description": "True when the step completes on a client action - its elapsed time is client-wait time."
          },
          "count": {
            "type": "integer",
            "description": "Completed/skipped executions of this step in the cohort - the n behind the distribution.",
            "format": "int32"
          },
          "avgElapsedDays": {
            "type": "number",
            "description": "Average elapsed days (previous done step's completion to this step's completion, idle\ntime included).",
            "format": "double"
          },
          "medianElapsedDays": {
            "type": "number",
            "description": "Median elapsed days.",
            "format": "double"
          },
          "p90ElapsedDays": {
            "type": "number",
            "description": "90th-percentile elapsed days - the tail where the money is.",
            "format": "double"
          },
          "bestElapsedDays": {
            "type": "number",
            "description": "Fastest elapsed days in the cohort.",
            "format": "double"
          },
          "worstElapsedDays": {
            "type": "number",
            "description": "Slowest elapsed days in the cohort.",
            "format": "double"
          },
          "bestTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "worstTask": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "avgActiveDays": {
            "type": "number",
            "description": "Average active days (step started to completed - queued vs genuinely slow).\nNull when no execution recorded a start timestamp.",
            "format": "double",
            "nullable": true
          },
          "medianActiveDays": {
            "type": "number",
            "description": "Median active days.",
            "format": "double",
            "nullable": true
          },
          "skippedCount": {
            "type": "integer",
            "description": "Executions that were skipped rather than completed (their elapsed time stays in the averages).",
            "format": "int32"
          },
          "totalChases": {
            "type": "integer",
            "description": "Total chase messages sent for this step across the cohort.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Per-step duration distribution across the workflow's occurrences. Steps are per-task\nsnapshots, so a step renamed in the template splits into separate rows - the per-step\ncount makes partial coverage visible."
      },
      "WorkflowStepAnalysisSummaryDto": {
        "type": "object",
        "properties": {
          "occurrenceCount": {
            "type": "integer",
            "description": "Occurrences (tasks spawned from the workflow) completed in the window - the n behind\nevery distribution in the report.",
            "format": "int32"
          },
          "avgTotalDays": {
            "type": "number",
            "description": "Average days from an occurrence's actual start to its completion. Null when the cohort is empty.",
            "format": "double",
            "nullable": true
          },
          "medianTotalDays": {
            "type": "number",
            "description": "Median days from start to completion.",
            "format": "double",
            "nullable": true
          },
          "avgClientWaitDays": {
            "type": "number",
            "description": "Average days per occurrence spent in client-wait steps (waiting on the client to act).",
            "format": "double",
            "nullable": true
          },
          "avgInternalDays": {
            "type": "number",
            "description": "Average days per occurrence spent in internal steps (practice-side time).",
            "format": "double",
            "nullable": true
          },
          "totalChases": {
            "type": "integer",
            "description": "Total chase messages sent across the cohort's steps.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Headline KPIs for the Workflow Step Analysis report."
      },
      "WorkflowStepAssignmentType": {
        "enum": [
          "TaskOwner",
          "SpecificUser",
          "ClientManager",
          "ClientServiceManager",
          "ClientPartner",
          "ClientAssociate",
          "DoNotAssign",
          "ClientServicePreparer",
          "ClientServiceReviewer"
        ],
        "type": "string",
        "example": "TaskOwner"
      },
      "WorkflowStepClientDataDto": {
        "type": "object",
        "properties": {
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepClientDataFieldDto"
            },
            "description": "The fields configured on this step with their current values and metadata.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response containing the current client field values for an UpdateClientData workflow step."
      },
      "WorkflowStepClientDataFieldDto": {
        "type": "object",
        "properties": {
          "fieldType": {
            "$ref": "#/components/schemas/DataFormQuestionType"
          },
          "clientField": {
            "$ref": "#/components/schemas/ClientCsvTargetField"
          },
          "customFieldDefinitionCode": {
            "type": "string",
            "description": "The custom field definition code when FieldType is CustomField.",
            "nullable": true
          },
          "label": {
            "type": "string",
            "description": "Display label for the field.",
            "nullable": true
          },
          "dataType": {
            "$ref": "#/components/schemas/CustomFieldDataType"
          },
          "currentValue": {
            "type": "string",
            "description": "The current value on the client record.",
            "nullable": true
          },
          "instructions": {
            "type": "string",
            "description": "Optional instructions for this field (with tokens resolved).",
            "nullable": true
          },
          "isRequired": {
            "type": "boolean",
            "description": "Whether this field must be filled before completing the step."
          },
          "sortOrder": {
            "type": "integer",
            "description": "Display order within the step.",
            "format": "int32"
          },
          "displayWidth": {
            "$ref": "#/components/schemas/FieldDisplayWidth"
          },
          "options": {
            "type": "string",
            "description": "JSON array of allowed values for Select/MultiSelect data types.",
            "nullable": true
          },
          "maxLength": {
            "type": "integer",
            "description": "Maximum character length for Text and TextArea types.",
            "format": "int32",
            "nullable": true
          },
          "validationPattern": {
            "type": "string",
            "description": "Client-facing validation regex pattern.",
            "nullable": true
          },
          "validationMessage": {
            "type": "string",
            "description": "Client-facing validation error message.",
            "nullable": true
          },
          "booleanDisplayMode": {
            "$ref": "#/components/schemas/BooleanDisplayMode"
          },
          "defaultValue": {
            "type": "string",
            "description": "Optional default value configured on the step template.\nUsed to pre-fill the input when the user opens the form.",
            "nullable": true
          },
          "clearValue": {
            "type": "boolean",
            "description": "Whether the step is configured to clear this field, so the form opens blank rather than\npre-filled with the current value."
          }
        },
        "additionalProperties": false,
        "description": "A single field with its current value and rendering metadata."
      },
      "WorkflowStepClientDataValueDto": {
        "type": "object",
        "properties": {
          "clientField": {
            "$ref": "#/components/schemas/ClientCsvTargetField"
          },
          "customFieldDefinitionCode": {
            "type": "string",
            "description": "The custom field definition code (mutually exclusive with ClientField).",
            "nullable": true
          },
          "value": {
            "type": "string",
            "description": "The value to set.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A single field value being saved."
      },
      "WorkflowStepDetailsDto": {
        "type": "object",
        "properties": {
          "step": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "workflowGroup": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "groupDeadline": {
            "type": "string",
            "description": "The deadline for the workflow group containing this step",
            "format": "date-time",
            "nullable": true
          },
          "plannedDate": {
            "type": "string",
            "description": "The date this step is planned for. Null means the step sits on the task's start date.",
            "format": "date",
            "nullable": true
          },
          "plannedTime": {
            "type": "string",
            "description": "Time of day on SodiumHQ.DTOs.WorkItems.WorkflowStepDetailsDto.PlannedDate. Null means the task's start time.",
            "format": "time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TaskItemStatus"
          },
          "isOverdue": {
            "type": "boolean",
            "description": "Indicates if the workflow step is overdue (GroupDeadline is before today and status is not Completed or Skipped)",
            "readOnly": true
          },
          "blockedReason": {
            "type": "string",
            "description": "The reason this step is blocked. Only populated when Status is Blocked.",
            "nullable": true
          },
          "completedDate": {
            "type": "string",
            "description": "When this workflow step was completed (if applicable)",
            "format": "date-time",
            "nullable": true
          },
          "assignedTo": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "canStart": {
            "type": "boolean",
            "description": "Indicates whether this step can be started based on its dependency requirements"
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this workflow step",
            "nullable": true
          },
          "scheduledSendCode": {
            "type": "string",
            "description": "Code of the send waiting to go out for this step, if one is scheduled",
            "nullable": true
          },
          "scheduledSendAt": {
            "type": "string",
            "description": "When the scheduled send is due to go out (UTC), if one is scheduled",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Details about a specific workflow step when a TaskItemDto represents a workflow step view"
      },
      "WorkflowStepDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "timeEstimateMinutes": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "plannedDateOffsetValue": {
            "maximum": 3650,
            "minimum": 0,
            "type": "integer",
            "description": "How many PlannedDateOffsetUnits after the task's start date, or before its due date, this step is\nplanned for on a task. Null means the step sits on the task's start date. Set together with PlannedDateRelativeTo.",
            "format": "int32",
            "nullable": true
          },
          "plannedDateOffsetUnit": {
            "$ref": "#/components/schemas/RecurrenceUnit"
          },
          "plannedDateRelativeTo": {
            "$ref": "#/components/schemas/DeadlineReferenceType"
          },
          "plannedTime": {
            "type": "string",
            "description": "Time of day on the planned date, when the step's automation may run. Null means the task's\nstart time. Only valid alongside a planned date.",
            "format": "time",
            "nullable": true
          },
          "stepNumber": {
            "maximum": 2147483647,
            "minimum": 0,
            "type": "integer",
            "description": "The step number within the workflow group.\nUsed for ordering steps and referencing dependencies.\nIf 0-based numbering is provided, it will be automatically converted to 1-based.",
            "format": "int32"
          },
          "stepType": {
            "$ref": "#/components/schemas/WorkflowStepType"
          },
          "autoExecute": {
            "type": "boolean",
            "description": "Whether this step executes automatically when its dependencies are met.\nFalse means the user must manually trigger execution.\nOnly relevant for executable step types (SendEmail, DocumentRequest, ClientConfirmation)."
          },
          "assignmentType": {
            "$ref": "#/components/schemas/WorkflowStepAssignmentType"
          },
          "assignedUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "billableService": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "dependsOnStepNumbers": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The step numbers that this step depends on (must be completed first).\nCan use either 0-based [0, 1] or 1-based [1, 2] numbering - 0-based will be auto-converted.\nExample: [1, 2] means this step depends on steps 1 and 2 being completed first.",
            "nullable": true
          },
          "emailStepConfiguration": {
            "$ref": "#/components/schemas/EmailStepConfigDto"
          },
          "documentRequestStepConfiguration": {
            "$ref": "#/components/schemas/DocumentRequestStepConfigDto"
          },
          "documentApprovalStepConfiguration": {
            "$ref": "#/components/schemas/DocumentApprovalStepConfigDto"
          },
          "documentUploadStepConfiguration": {
            "$ref": "#/components/schemas/DocumentUploadStepConfigDto"
          },
          "clientConfirmationStepConfiguration": {
            "$ref": "#/components/schemas/ClientConfirmationStepConfigDto"
          },
          "sendDataFormStepConfiguration": {
            "$ref": "#/components/schemas/SendDataFormStepConfigDto"
          },
          "setServiceStageStepConfiguration": {
            "$ref": "#/components/schemas/SetServiceStageStepConfigDto"
          },
          "setPipelineStageStepConfiguration": {
            "$ref": "#/components/schemas/SetPipelineStageStepConfigDto"
          },
          "updateClientDataStepConfiguration": {
            "$ref": "#/components/schemas/UpdateClientDataStepConfigDto"
          },
          "reviewLoggedTimeStepConfiguration": {
            "$ref": "#/components/schemas/ReviewLoggedTimeStepConfigDto"
          },
          "billForWorkStepConfiguration": {
            "$ref": "#/components/schemas/BillForWorkStepConfigDto"
          },
          "cisCollectPaymentsStepConfiguration": {
            "$ref": "#/components/schemas/CisCollectPaymentsStepConfigDto"
          },
          "cisConfirmReturnStepConfiguration": {
            "$ref": "#/components/schemas/CisConfirmReturnStepConfigDto"
          },
          "cisSubmitReturnStepConfiguration": {
            "$ref": "#/components/schemas/CisSubmitReturnStepConfigDto"
          },
          "cisVerifySubcontractorsStepConfiguration": {
            "$ref": "#/components/schemas/CisVerifySubcontractorsStepConfigDto"
          },
          "cisFileNilReturnStepConfiguration": {
            "$ref": "#/components/schemas/CisFileNilReturnStepConfigDto"
          },
          "cisRemindPaymentsStepConfiguration": {
            "$ref": "#/components/schemas/CisRemindPaymentsStepConfigDto"
          },
          "textMessageStepConfiguration": {
            "$ref": "#/components/schemas/SendTextMessageStepConfigDto"
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this workflow step template",
            "nullable": true
          },
          "condition": {
            "$ref": "#/components/schemas/ConditionDto"
          },
          "clientTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientType"
            },
            "description": "The types of clients this step is applicable to.\nAn empty list means the step applies to all client types.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "DTO for workflow steps within a workflow group.\nUsed for both create/update requests and GET responses for workflow templates."
      },
      "WorkflowStepEmailPreviewAttachmentDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Practice document code.",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "description": "File name the attachment will be sent with.",
            "nullable": true
          },
          "fileSize": {
            "type": "integer",
            "description": "File size in bytes.",
            "format": "int64"
          },
          "contentType": {
            "type": "string",
            "description": "MIME type of the file.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A pre-specified practice document attachment shown in the email preview / compose dialog."
      },
      "WorkflowStepEmailPreviewDto": {
        "type": "object",
        "properties": {
          "subject": {
            "type": "string",
            "description": "Rendered subject line with Liquid tokens resolved.",
            "nullable": true
          },
          "bodyHtml": {
            "type": "string",
            "description": "Rendered body HTML with header/footer/theme applied and Liquid tokens resolved.",
            "nullable": true
          },
          "toRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailPreviewRecipientDto"
            },
            "description": "Resolved To recipients with names and email addresses.",
            "nullable": true
          },
          "ccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailPreviewRecipientDto"
            },
            "description": "Resolved CC recipients with names and email addresses.",
            "nullable": true
          },
          "bccRecipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailPreviewRecipientDto"
            },
            "description": "Resolved BCC recipients with names and email addresses.",
            "nullable": true
          },
          "fromConfigCode": {
            "type": "string",
            "description": "Suggested From connection (email config code): the client manager match if one applies, else the tenant default.",
            "nullable": true
          },
          "unresolvedTokens": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Names of the placeholders that resolved to nothing, so the caller can warn about them.\nOnly populated by previews that asked for unresolved-token highlighting.",
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepEmailPreviewAttachmentDto"
            },
            "description": "Pre-specified practice document attachments from the step configuration.\nMetadata only (no content). Documents that no longer exist are omitted;\nsend-time validation surfaces the breakage.",
            "nullable": true
          },
          "documentRequestCode": {
            "type": "string",
            "description": "For a Document Request step, the code of the request the step sends (the Draft the preview\ncreated, or the one it already had). Null for other step types.",
            "nullable": true
          },
          "documentRequestItems": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentRequestStepItemDto"
            },
            "description": "For a Document Request step, the items on that request in order. Empty for a request without\nitems and for other step types.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Preview of a workflow step email with rendered content and resolved recipients.\nReturned before sending so the user can review what will be sent."
      },
      "WorkflowStepProgressDto": {
        "type": "object",
        "properties": {
          "stepNumber": {
            "type": "integer",
            "description": "Sequential step number within the task (1, 2, 3, etc.).\nUsed for referencing the step in API calls and ordering.\nUnique across all groups within this task.",
            "format": "int32"
          },
          "stepName": {
            "type": "string",
            "description": "The name of the workflow step from the template.\nDescribes what needs to be done in this step.",
            "nullable": true
          },
          "stepDescription": {
            "type": "string",
            "description": "The detailed description of the workflow step from the template.\nProvides instructions or context for completing the step.",
            "nullable": true
          },
          "stepTimeEstimateMinutes": {
            "type": "integer",
            "description": "The estimated time to complete the workflow step, in whole minutes.\nInherited from the WorkflowStep template for time planning and estimation.",
            "format": "int32",
            "nullable": true
          },
          "plannedDate": {
            "type": "string",
            "description": "The date this step is planned for. Null means the step sits on the task's start date.",
            "format": "date",
            "nullable": true
          },
          "plannedTime": {
            "type": "string",
            "description": "Time of day on PlannedDate. Null means the task's start time.",
            "format": "time",
            "nullable": true
          },
          "status": {
            "type": "string",
            "description": "The current status of this workflow step instance.\nUses TaskItemStatus enum values (NotStarted, InProgress, Blocked, Completed, Skipped).",
            "nullable": true
          },
          "blockedReason": {
            "type": "string",
            "description": "The reason this step is blocked. Only returned when the status is \"Blocked\".",
            "nullable": true
          },
          "assignedUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "assignedTeam": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "completedByUser": {
            "$ref": "#/components/schemas/CodeAndNameDto"
          },
          "completedDate": {
            "type": "string",
            "description": "The date and time when this step was completed.\nNull if the step is not yet completed.\nUsed for tracking completion timeline and performance metrics.",
            "format": "date-time",
            "nullable": true
          },
          "canStart": {
            "type": "boolean",
            "description": "Whether this step can be started based on its dependencies.\nTrue if all prerequisite steps are completed, false otherwise.\nUsed by the UI to enable/disable step actions."
          },
          "stepType": {
            "$ref": "#/components/schemas/WorkflowStepType"
          },
          "autoExecute": {
            "type": "boolean",
            "description": "Whether this step executes automatically when its dependencies are met.\nFalse means the user must manually trigger execution.\nOnly relevant for executable step types (SendEmail, DocumentRequest, ClientConfirmation)."
          },
          "emailStepConfiguration": {
            "$ref": "#/components/schemas/EmailStepConfigDto"
          },
          "emailExecutionState": {
            "$ref": "#/components/schemas/EmailExecutionStateDto"
          },
          "documentRequestStepConfiguration": {
            "$ref": "#/components/schemas/DocumentRequestStepConfigDto"
          },
          "documentRequestExecutionState": {
            "$ref": "#/components/schemas/DocumentRequestExecutionStateDto"
          },
          "documentApprovalStepConfiguration": {
            "$ref": "#/components/schemas/DocumentApprovalStepConfigDto"
          },
          "documentApprovalExecutionState": {
            "$ref": "#/components/schemas/DocumentApprovalExecutionStateDto"
          },
          "documentUploadStepConfiguration": {
            "$ref": "#/components/schemas/DocumentUploadStepConfigDto"
          },
          "documentUploadExecutionState": {
            "$ref": "#/components/schemas/DocumentUploadExecutionStateDto"
          },
          "linkedDocumentApprovalStatus": {
            "$ref": "#/components/schemas/ClientApprovalStatus"
          },
          "linkedDocumentCount": {
            "type": "integer",
            "description": "How many client documents are linked to this step. A document approval step can cover several.",
            "format": "int32"
          },
          "approvedDocumentCount": {
            "type": "integer",
            "description": "How many of the linked client documents the client has approved.",
            "format": "int32"
          },
          "scheduledSendCode": {
            "type": "string",
            "description": "The code of this step's send that is still waiting to go out, for changing its time or\ncancelling it from the step. Null when the step has nothing scheduled.",
            "nullable": true
          },
          "scheduledSendAt": {
            "type": "string",
            "description": "When this step's pending send is due to go out. Null when the step has nothing scheduled.",
            "format": "date-time",
            "nullable": true
          },
          "outstandingClientRequest": {
            "$ref": "#/components/schemas/OutstandingClientRequestType"
          },
          "clientConfirmationStepConfiguration": {
            "$ref": "#/components/schemas/ClientConfirmationStepConfigDto"
          },
          "clientConfirmationExecutionState": {
            "$ref": "#/components/schemas/ClientConfirmationExecutionStateDto"
          },
          "sendDataFormStepConfiguration": {
            "$ref": "#/components/schemas/SendDataFormStepConfigDto"
          },
          "sendDataFormExecutionState": {
            "$ref": "#/components/schemas/SendDataFormExecutionStateDto"
          },
          "setServiceStageStepConfiguration": {
            "$ref": "#/components/schemas/SetServiceStageStepConfigDto"
          },
          "setPipelineStageStepConfiguration": {
            "$ref": "#/components/schemas/SetPipelineStageStepConfigDto"
          },
          "updateClientDataStepConfiguration": {
            "$ref": "#/components/schemas/UpdateClientDataStepConfigDto"
          },
          "reviewLoggedTimeStepConfiguration": {
            "$ref": "#/components/schemas/ReviewLoggedTimeStepConfigDto"
          },
          "billForWorkStepConfiguration": {
            "$ref": "#/components/schemas/BillForWorkStepConfigDto"
          },
          "billForWorkExecutionState": {
            "$ref": "#/components/schemas/BillForWorkExecutionStateDto"
          },
          "cisCollectPaymentsStepConfiguration": {
            "$ref": "#/components/schemas/CisCollectPaymentsStepConfigDto"
          },
          "cisCollectPaymentsExecutionState": {
            "$ref": "#/components/schemas/CisCollectPaymentsExecutionStateDto"
          },
          "cisConfirmReturnStepConfiguration": {
            "$ref": "#/components/schemas/CisConfirmReturnStepConfigDto"
          },
          "cisConfirmReturnExecutionState": {
            "$ref": "#/components/schemas/CisConfirmReturnExecutionStateDto"
          },
          "cisSubmitReturnStepConfiguration": {
            "$ref": "#/components/schemas/CisSubmitReturnStepConfigDto"
          },
          "cisSubmitReturnExecutionState": {
            "$ref": "#/components/schemas/CisSubmitReturnExecutionStateDto"
          },
          "cisVerifySubcontractorsStepConfiguration": {
            "$ref": "#/components/schemas/CisVerifySubcontractorsStepConfigDto"
          },
          "cisVerifySubcontractorsExecutionState": {
            "$ref": "#/components/schemas/CisVerifySubcontractorsExecutionStateDto"
          },
          "cisFileNilReturnStepConfiguration": {
            "$ref": "#/components/schemas/CisFileNilReturnStepConfigDto"
          },
          "cisRemindPaymentsStepConfiguration": {
            "$ref": "#/components/schemas/CisRemindPaymentsStepConfigDto"
          },
          "cisRemindPaymentsExecutionState": {
            "$ref": "#/components/schemas/CisRemindPaymentsExecutionStateDto"
          },
          "textMessageStepConfiguration": {
            "$ref": "#/components/schemas/SendTextMessageStepConfigDto"
          },
          "textMessageExecutionState": {
            "$ref": "#/components/schemas/SendTextMessageExecutionStateDto"
          },
          "textSends": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientRequestTextDto"
            },
            "description": "The texts a client send step sent (or is holding) with its emails when it asks to also send a text, oldest first:\neach send of the email, resends included, adds one per contact texted. Null when it has sent none.",
            "nullable": true
          },
          "notes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NoteDto"
            },
            "description": "Notes attached to this workflow step.\nUses the TaskItemNote system for rich note support including pinning.",
            "nullable": true
          },
          "dependsOnSteps": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Sequential step numbers that this step depends on within this task.\nThese are the StepNumber values (e.g., [2, 5, 7]).\nThese steps must be completed before this step can be started.",
            "nullable": true
          },
          "checklist": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemDto"
            },
            "description": "Checklist items for this workflow step instance",
            "nullable": true
          },
          "chase": {
            "$ref": "#/components/schemas/ChaseScheduleDto"
          },
          "isOmitted": {
            "type": "boolean",
            "description": "Whether this step is omitted because its visibility condition is not met by the\ntask's primary client. Omitted steps are excluded from progress counts, satisfy\ndependencies, and cannot be actioned."
          },
          "omittedReason": {
            "type": "string",
            "description": "Human-readable explanation of why this step is omitted. Null when not omitted.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents the progress of a single workflow step within a TaskItem.\nContains both the step template information and the current execution status.\n            \nAPI Usage:\n- Part of TaskWorkflowProgressDto responses\n- Returned by individual step operations\n- Used for step-level progress tracking and assignment management"
      },
      "WorkflowStepReference": {
        "required": [
          "taskCode"
        ],
        "type": "object",
        "properties": {
          "taskCode": {
            "minLength": 1,
            "type": "string",
            "description": "The task code containing the workflow step."
          },
          "groupNumber": {
            "type": "integer",
            "description": "The group number within the workflow.",
            "format": "int32"
          },
          "stepNumber": {
            "type": "integer",
            "description": "The step number within the group.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Identifies a specific workflow step within a task."
      },
      "WorkflowStepTextPreviewDto": {
        "type": "object",
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "isPracticeRouted": {
            "type": "boolean",
            "description": "The step is on the practice's default: the practice's routing chooses each recipient's channel"
          },
          "recipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowStepTextPreviewRecipientDto"
            },
            "description": "The people the step would text, one per number, each with the text rendered for them",
            "nullable": true
          },
          "missed": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextMessageMissedDto"
            },
            "description": "The people chosen who would not be texted, and why: no contact of a type, no mobile, a number that cannot be\nread, on the do-not-text list",
            "nullable": true
          },
          "blockers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What would stop the step texting anyone, each as the step would show it when blocked: messaging not set up, no\nnumber to text from, the text template gone, nobody to text. Empty when it can send.",
            "nullable": true
          },
          "heldUntil": {
            "type": "string",
            "description": "When an automatic step would run now inside the practice's quiet hours: the end of them (UTC), when it would\nsend. Null for a step sent by hand, which always goes at once, and outside quiet hours.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "What a Send Text Message step on a task would do if it ran now (docs/features/WorkflowTextMessages/PLAN.md, \"API\nsurface\"): who it would text and with what, who it would miss and why, what would stop it texting anyone, and when\nan automatic run would wait for the practice's quiet hours. Nothing is sent or stored, and no cost is shown (D14)."
      },
      "WorkflowStepTextPreviewRecipientDto": {
        "type": "object",
        "properties": {
          "contactCode": {
            "type": "string",
            "description": "The contact's code",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The contact's name",
            "nullable": true
          },
          "address": {
            "type": "string",
            "description": "The mobile number the text goes to, E.164",
            "nullable": true
          },
          "isKnownOnWhatsApp": {
            "type": "boolean",
            "description": "The number is known on WhatsApp to the practice, from the Messaging Service's recipients check: the WhatsApp icon\nbeside it. False when the service could not be read, and for someone already texted (not checked again)."
          },
          "channel": {
            "$ref": "#/components/schemas/MessageChannel"
          },
          "smsReason": {
            "type": "string",
            "description": "Why the text would go by SMS where WhatsApp might have been; null when it would go by WhatsApp or there is\nnothing to say",
            "nullable": true
          },
          "text": {
            "type": "string",
            "description": "The text as this person would get it: on WhatsApp the template's text with the variables filled in (empty when\nthe template's text could not be read); null when the step's template can't be sent",
            "nullable": true
          },
          "isAlreadyTexted": {
            "type": "boolean",
            "description": "True when an earlier run of the step already texted this person: sending again skips them"
          }
        },
        "additionalProperties": false,
        "description": "One person a text step would text"
      },
      "WorkflowStepTextTemplatePreviewDto": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "The text, rendered for the client given (and the first of its contacts the step would text), or with no client;\non WhatsApp the template's text with the variables filled in",
            "nullable": true
          },
          "whatsAppText": {
            "type": "string",
            "description": "On the practice's default, the WhatsApp template's text with the variables filled in, beside the SMS text in\ntext; null on a step with one channel",
            "nullable": true
          },
          "contactCode": {
            "type": "string",
            "description": "The contact whose details fill the {{ Contact.* }} tokens: the first person the step would text on the client;\nnull with no client, or when it would text nobody",
            "nullable": true
          },
          "contactName": {
            "type": "string",
            "description": "That contact's name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A text step's text rendered in the workflow editor"
      },
      "WorkflowStepType": {
        "enum": [
          "Standard",
          "SendEmail",
          "DocumentRequest",
          "DocumentApproval",
          "ClientConfirmation",
          "SendDataForm",
          "SetServiceStage",
          "UpdateClientData",
          "SetPipelineStage",
          "DocumentUpload",
          "ReviewLoggedTime",
          "BillForWork",
          "CisCollectPayments",
          "CisConfirmReturn",
          "CisSubmitReturn",
          "CisVerifySubcontractors",
          "CisFileNilReturn",
          "CisRemindPayments",
          "SendTextMessage"
        ],
        "type": "string",
        "example": "Standard"
      },
      "WorkingDaySettingsDto": {
        "type": "object",
        "properties": {
          "defaultHolidayAdjustment": {
            "$ref": "#/components/schemas/HolidayAdjustment"
          },
          "bankHolidayRegion": {
            "$ref": "#/components/schemas/BankHolidayRegion"
          },
          "workingDays": {
            "$ref": "#/components/schemas/WorkingDays"
          }
        },
        "additionalProperties": false,
        "description": "Working day settings for a tenant"
      },
      "WorkingDays": {
        "enum": [
          "None",
          "Monday",
          "Tuesday",
          "Wednesday",
          "Thursday",
          "Friday",
          "StandardWeek",
          "Saturday",
          "SixDayWeek",
          "Sunday",
          "AllDays"
        ],
        "type": "string",
        "example": "None"
      },
      "WorkingPatternDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this working pattern",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name of the pattern, e.g. \"Full time\" or \"Part time (Mon/Wed/Fri)\"",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether this is the tenant's default pattern — the one members who aren't on a\nspecific pattern are measured against. Exactly one pattern per tenant carries this"
          },
          "expectedMinutesMonday": {
            "type": "integer",
            "description": "Minutes expected on a Monday (7.5 hours = 450). Zero means a non-working day",
            "format": "int32"
          },
          "expectedMinutesTuesday": {
            "type": "integer",
            "description": "Minutes expected on a Tuesday. Zero means a non-working day",
            "format": "int32"
          },
          "expectedMinutesWednesday": {
            "type": "integer",
            "description": "Minutes expected on a Wednesday. Zero means a non-working day",
            "format": "int32"
          },
          "expectedMinutesThursday": {
            "type": "integer",
            "description": "Minutes expected on a Thursday. Zero means a non-working day",
            "format": "int32"
          },
          "expectedMinutesFriday": {
            "type": "integer",
            "description": "Minutes expected on a Friday. Zero means a non-working day",
            "format": "int32"
          },
          "expectedMinutesSaturday": {
            "type": "integer",
            "description": "Minutes expected on a Saturday. Zero means a non-working day",
            "format": "int32"
          },
          "expectedMinutesSunday": {
            "type": "integer",
            "description": "Minutes expected on a Sunday. Zero means a non-working day",
            "format": "int32"
          },
          "totalWeeklyMinutes": {
            "type": "integer",
            "description": "The total minutes expected across the whole week — the sum of the seven days",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A named working week team members can be put on, holding the minutes expected on each\nday. The Team Time report measures each member against their pattern, or the tenant's\ndefault pattern when they aren't on a specific one."
      },
      "WorkingPatternDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkingPatternDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "WorkingPatternSortField": {
        "enum": [
          "Name",
          "IsDefault"
        ],
        "type": "string",
        "example": "Name"
      },
      "WriteOffReasonDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for this reason",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The display name, e.g. \"Quoted fixed fee\"",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer",
            "description": "Position in the reason picker",
            "format": "int32"
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the reason is offered for new write-offs"
          }
        },
        "additionalProperties": false,
        "description": "A reason for writing time off (or on) against a fee. Tenant-configurable; deactivated\nrather than deleted once used."
      },
      "WriteOffReasonDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WriteOffReasonDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "WriteOffReasonSortField": {
        "enum": [
          "SortOrder",
          "Name"
        ],
        "type": "string",
        "example": "SortOrder"
      },
      "WriteOffReportDto": {
        "type": "object",
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/WriteOffSummaryDto"
          },
          "rows": {
            "$ref": "#/components/schemas/WriteOffRowDtoPagedResult"
          },
          "generatedAt": {
            "type": "string",
            "description": "When the report was generated (UTC)",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The Write-off Analysis report: time written off (or on) against fees over a period, by\nreason, team member or client. The cohort is every time allocation recorded in the window,\ndated by when the disposal was recorded rather than when the time was worked. Recovery here\nis measured against Sodium's billing lines, not the invoice the accounting platform issued."
      },
      "WriteOffRowDto": {
        "type": "object",
        "properties": {
          "groupCode": {
            "type": "string",
            "description": "The group's code; null for the \"No reason\" / \"No client\" row",
            "nullable": true
          },
          "groupName": {
            "type": "string",
            "description": "The group's display name",
            "nullable": true
          },
          "settledValue": {
            "type": "number",
            "description": "WIP settled by the group's adjusted allocations",
            "format": "double"
          },
          "billedAmount": {
            "type": "number",
            "description": "What clients were charged for it",
            "format": "double"
          },
          "writtenOffAmount": {
            "type": "number",
            "description": "Time written off in the group",
            "format": "double"
          },
          "writtenOnAmount": {
            "type": "number",
            "description": "Write-ons in the group, as a positive number",
            "format": "double"
          },
          "netWriteOffAmount": {
            "type": "number",
            "description": "Written off minus written on",
            "format": "double"
          },
          "shareOfNet": {
            "type": "number",
            "description": "The group's net write-off as a share of the report's net write-off, as a percentage;\nnull when the net is zero",
            "format": "double",
            "nullable": true
          },
          "adjustedAllocationCount": {
            "type": "integer",
            "description": "Adjusted allocations in the group",
            "format": "int32"
          },
          "adjustedEntryCount": {
            "type": "integer",
            "description": "Distinct time entries in the group touched by an adjustment",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "One group's row on the Write-off Analysis report: a reason, team member or client"
      },
      "WriteOffRowDtoPagedResult": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WriteOffRowDto"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "WriteOffSummaryDto": {
        "type": "object",
        "properties": {
          "settledValue": {
            "type": "number",
            "description": "WIP settled by allocations recorded in the window, billed or written off",
            "format": "double"
          },
          "billedAmount": {
            "type": "number",
            "description": "What clients were charged for that WIP on Sodium's billing lines",
            "format": "double"
          },
          "writtenOffAmount": {
            "type": "number",
            "description": "Time given away: the positive differences between settled and billed, summed",
            "format": "double"
          },
          "writtenOnAmount": {
            "type": "number",
            "description": "Fees above the time behind them: the negative differences, summed as a positive number",
            "format": "double"
          },
          "netWriteOffAmount": {
            "type": "number",
            "description": "Written off minus written on",
            "format": "double"
          },
          "recoveryRate": {
            "type": "number",
            "description": "Billed as a share of settled WIP, as a percentage; null when nothing was settled",
            "format": "double",
            "nullable": true
          },
          "adjustedAllocationCount": {
            "type": "integer",
            "description": "Allocations with a non-zero difference",
            "format": "int32"
          },
          "adjustedEntryCount": {
            "type": "integer",
            "description": "Distinct time entries touched by an adjusted allocation",
            "format": "int32"
          },
          "groupCount": {
            "type": "integer",
            "description": "Number of rows (groups) in the report",
            "format": "int32"
          },
          "startDate": {
            "type": "string",
            "description": "The window the report covers (inclusive)",
            "format": "date"
          },
          "endDate": {
            "type": "string",
            "description": "The window end the report covers (inclusive)",
            "format": "date"
          }
        },
        "additionalProperties": false,
        "description": "Headline aggregates for the Write-off Analysis report"
      },
      "WriteOffTimeEntriesRequest": {
        "required": [
          "timeEntryCodes",
          "writeOffReasonCode"
        ],
        "type": "object",
        "properties": {
          "timeEntryCodes": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The codes of the time entries to write off"
          },
          "amount": {
            "maximum": 100000000,
            "minimum": 0.01,
            "type": "number",
            "description": "Total WIP to write off across the entries. Omitted, every entry's open WIP is written off\nin full. Must not exceed the entries' total open WIP.",
            "format": "double",
            "nullable": true
          },
          "allocations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimeEntryAllocationRequest"
            },
            "description": "Explicit per-entry amounts (SettledValue is the write-off; BilledAmount is ignored).\nWhen supplied, every entry in TimeEntryCodes needs one and Amount is ignored.",
            "nullable": true
          },
          "writeOffReasonCode": {
            "minLength": 1,
            "type": "string",
            "description": "The code of the write-off reason (from the tenant's write-off reasons; must be active)"
          },
          "notes": {
            "maxLength": 500,
            "type": "string",
            "description": "Free-text context recorded on each allocation",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to write off open WIP on time entries with no bill raised. Omit the amount to write\noff everything still open on each entry; give an amount to spread it across the entries\npro rata to their open WIP (each capped at its own); or give explicit allocations to say\nexactly how much comes off each entry. A reason is always required."
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "description": "API Key required in 'x-api-key' header",
        "name": "x-api-key",
        "in": "header"
      },
      "OAuth2": {
        "type": "oauth2",
        "description": "OAuth2 implicit flow",
        "flows": {
          "implicit": {
            "authorizationUrl": "https://id.sodiumhq.com/authorize",
            "scopes": {
              "openid": "OpenID Connect",
              "profile": "User profile",
              "email": "Email address"
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "ApiKey": [ ]
    },
    {
      "OAuth2": [
        "openid",
        "profile",
        "email"
      ]
    }
  ],
  "tags": [
    {
      "name": "Agent Authorisations",
      "description": "The practice-wide view of which clients need HMRC agent authorisations and what is held against each. Rows are derived from the client's active or proposed services, not from authorisations already recorded, so a client who needs an authorisation nobody has requested still appears. Serves both the Making Tax Digital and the 64-8 views by taking the authorisation types the caller wants; counts are a separate call because the list is paged."
    },
    {
      "name": "AI",
      "description": "AI-powered features for content generation and usage tracking. Includes endpoints to configure AI settings per tenant (API keys, model selection), generate content for various activities (service descriptions, proposals, tooltips), and retrieve token usage summaries for monitoring AI consumption. All content generation uses OpenRouter with configurable models."
    },
    {
      "name": "Announcements",
      "description": "The currently active platform announcement banner. Returns the banner every user should see in-app right now (message variants for large and small screens, text and background colours, and the code used as the per-browser dismissal key), or 204 when none is active."
    },
    {
      "name": "API Keys",
      "description": "API key management for programmatic access to the Sodium API. Provides endpoints to create new API keys with custom names and expiration dates, list all API keys for the authenticated user, retrieve individual API key details, update API key properties, and revoke API keys. API keys enable secure server-to-server integrations and automation workflows."
    },
    {
      "name": "Broadcasts",
      "description": "Bulk Comms: the practice's bulk emails and bulk texts in one list, newest first, filterable by status and channel. Each kind is read and changed on its own routes (Email - Broadcasts, Text Broadcasts)."
    },
    {
      "name": "Budgets",
      "description": "Job budgets: the standard hours and fee budget on a service, how a client's service differs from it (follow it, adjust it by a percentage, or figures of its own), and progress against them per billing period. Hours need Job Budgets; the fee and the value of time need Fee Budgets, and are masked from responses without it."
    },
    {
      "name": "Calendar Feed",
      "description": "Per-user iCalendar (.ics) subscription feeds. Users get a secret feed URL they can subscribe to from Google Calendar, Outlook or Apple Calendar, showing their tasks on their start dates. The feed endpoint itself is anonymous — calendar clients cannot authenticate, so the token in the URL is the credential and can be reset if it leaks."
    },
    {
      "name": "Calendar Subscriptions",
      "description": "External calendars subscribed to by ICS URL — the inbound mirror of Calendar Feed. Each user can hold several subscriptions (Google/Outlook/Apple secret addresses), each with a display colour and visibility toggle; their events are expanded server-side (recurrences included, times converted to practice wall clock) and overlaid on the task calendar. Feeds are fetched on demand through a 30-minute server-side cache with SSRF-guarded URLs."
    },
    {
      "name": "Charity Commission",
      "description": "Read-only lookups against the Charity Commission for England and Wales register. Search charities by name and retrieve a charity's register entry (name, type, status, contact details and any Companies House number), its annual return and accounts filings (raw, and mapped to key dates) and its trustees by charity number. Nothing here writes to a client: the web app saves confirmed values through the business-details, client-dates and client-contacts updates."
    },
    {
      "name": "Client - Agent Authorisations",
      "description": "Manage HMRC 64-8 agent authorisation statuses for individual clients. Returns all 11 authorisation types with a user-managed status (Not Requested, Requested, Granted) and a computed IsRequired flag derived from the client's active or proposed services."
    },
    {
      "name": "Client Billable Services",
      "description": "Top-level client billable service queries not scoped to a single client. Returns lightweight summary projections designed for kanban board display, with filtering by service code and stage code. Also provides a PATCH endpoint for updating only the stage (used for drag-and-drop)."
    },
    {
      "name": "Client Billing - Line Items",
      "description": "Tenant-wide view of billing line items across all clients. Supports pagination and filtering by status, client, and billing date range. For client-scoped operations (approve, cancel) see the Client - Billing - Lines tag."
    },
    {
      "name": "Client - Billing - Lines",
      "description": "Billable line items promoted from the client's billing schedule. Lines accumulate until bundled into an invoice submission. Supports listing, retrieval, editing and deletion (an Invoiced line cannot be deleted, and a line cannot be edited while its submission is Pending). Items progress through statuses: Pending → Approved → Invoiced (or Cancelled)."
    },
    {
      "name": "Client - Billing - Schedule",
      "description": "A client's billing schedule: every charge Sodium plans to raise for the client, past and future, one row per occurrence. Occurrences are generated from the client's service and package rules (12 months ahead), or added by hand as ad hoc charges. Scheduled items become billing lines on their billing date; rows can be skipped, edited or billed now."
    },
    {
      "name": "Client Billing - Schedule",
      "description": "Practice-wide view of the billing schedule: planned billing totals by month across all clients."
    },
    {
      "name": "Client Billing - Settings",
      "description": "Tenant-level settings for recurring client billing and invoicing defaults. Enable or disable the billing module, configure default invoice day of month, payment terms, line item approval requirements, and default accounting codes."
    },
    {
      "name": "Client Billing - Submissions",
      "description": "Tenant-wide view of invoice submissions across all clients. Supports pagination and filtering by status, client, and billing date range. For client-scoped operations (submit, retry, projected) see the Client - Billing - Submissions tag."
    },
    {
      "name": "Client - Billing - Submissions",
      "description": "Invoice submissions represent batches of approved billable line items pushed to the connected accounting platform. Each submission tracks the external invoice ID/number, submission status, and any error messages from failed attempts."
    },
    {
      "name": "Client - Books",
      "description": "A client's OWN accounting software: the organisation their record is bound to, and the invoices, contacts, bank accounts and profit and loss inside it. Distinct from the client's customer record in the practice's books, which is what the practice invoices them against. Organisations are always read live from the platform rather than a stored list, one client may be bound to one organisation and one organisation to one client, and platforms that offer no profit and loss report say so with a 400 rather than an empty report."
    },
    {
      "name": "Client - Business Details",
      "description": "Manage business-specific information for clients that are businesses (non-companies). Provides get and update operations for business details including trading name, business type, registration information, and other business-specific data. This is a one-to-one relationship with Client entities of type Business, complementing Company Details for corporate clients."
    },
    {
      "name": "Client - Confirmations",
      "description": "Tenant-wide list of client confirmation workflow steps. Returns a paged list of confirmation steps across all clients with filtering by status and client code. Used by the Requests page to show outstanding client confirmations."
    },
    {
      "name": "Client - Contacts",
      "description": "Manage contacts associated with specific clients. Provides standard CRUD operations for client contacts including creation, retrieval, updating, and deletion. Client contacts are scoped to individual clients and include contact type, name, email, phone, and other contact information."
    },
    {
      "name": "Client - Custom Fields",
      "description": "Manage custom field values for individual clients. Custom fields are defined at the tenant level and values are stored per client. Supports getting all field definitions with their current values for a client, and setting/updating values with type validation (text, number, date, boolean, select, multi-select)."
    },
    {
      "name": "Client - Dates",
      "description": "Manage key dates for individual clients including year-end, tax deadlines, and other compliance-related dates. Provides get and save operations for client date management."
    },
    {
      "name": "Client - Document Requests",
      "description": "Manage document requests for clients. Create requests asking clients to provide specific documents, track submissions and review responses. Supports the full lifecycle: Draft → Open → Submitted → Accepted/Rejected/Cancelled. Documents can be uploaded by staff or portal clients, and submissions include comments and review workflows."
    },
    {
      "name": "Client - Documents",
      "description": "Manage documents associated with specific clients. Supports creating, listing, updating, and deleting client documents. Includes filtering by document type and review status. Documents uploaded by clients via the portal start with ReviewStatus=PendingReview and must be approved or rejected by an internal user. The list endpoint defaults to showing only Approved documents — use the reviewStatus filter parameter to view PendingReview or Rejected documents. Also serves a tenant-wide list of client documents across all clients, defaulting to only those sent for client approval, used by the Requests page to show outstanding document approvals."
    },
    {
      "name": "Client - Email Rules",
      "description": "Rules that associate emails with a client. Each rule is an email address (e.g. john@acme.com), a domain (e.g. acme.com), or a specific message ID (GUID). Email addresses match that exact sender/recipient, domains match all emails from that domain, and message IDs pin a specific email to the client. The same value can be a rule for multiple clients."
    },
    {
      "name": "Client - Emails",
      "description": "Returns emails associated with a client based on its configured rules. Queries all connected mailboxes using the client's rules as filters and returns matching conversations. Supports direction, search, and pagination."
    },
    {
      "name": "Client - Links",
      "description": "Manage external links associated with specific clients. Provides CRUD operations for client links which can point to external resources, websites, or portals relevant to the client. Links include URL, description, and link type information."
    },
    {
      "name": "Client - Meeting Notes",
      "description": "Records of meetings and calls with a client: title, start and end time, how it took place, the contacts and staff who attended, a summary, the full content (usually a transcript), links such as the recording, and optionally the task it was about. Written by practice staff or pushed in by a VoIP/AI integration. Times must carry a time zone and are stored as UTC; summary and content are HTML, and plain text sent there is kept with its line breaks. A deleted attendee stays on the record by name."
    },
    {
      "name": "Client - MTD Nominal Mappings",
      "description": "Mapping a client's chart of accounts to the boxes of an MTD Income Tax quarterly update, per income source, and pulling the cumulative period's figures from their connected books into a draft for review. Before anything is confirmed the mapping is a suggestion built from the platform's shipped catalogue crossed with the client's live chart; ambiguous accounts are left blank rather than guessed. Figures never leave here for HMRC — the quarterly-updates save and submit path does that — and disallowable expenses are never filled in, because a chart of accounts has no concept of the split."
    },
    {
      "name": "Client - MTD Adjustable Summaries",
      "description": "Business source adjustable summaries (BSAS) for a client's MTD Income Tax income sources — HMRC's accounting result for a period, which the practice reviews and adjusts before the tax return. Adjustments are amounts to add or subtract rather than replacements, and HMRC accept them only once per summary, so a correction means triggering a fresh summary."
    },
    {
      "name": "Client - MTD Annual Submissions",
      "description": "Year-end adjustments, allowances and non-financial declarations for a client's MTD Income Tax income sources. Unlike a quarterly update these are data updates rather than filings with deadlines: HMRC holds the authoritative values, a save replaces them in full, and the retrieve re-shows whatever software last sent them. Who sent or deleted a submission from Sodium is recorded separately, because HMRC's own retrieve never says."
    },
    {
      "name": "Client - MTD Capital Gains",
      "description": "A client's capital gains for a tax year under MTD Income Tax, across HMRC's two resources: everything other than UK residential property (listed and unlisted shares, crypto-assets, other assets), and UK residential property disposals reported for Self Assessment. Both are full replacements at HMRC — a save carries every disposal that should survive, because anything absent is cleared. Reporting a residential disposal here does not discharge the in-year property payment-on-account return due within 60 days of completion."
    },
    {
      "name": "Client - MTD Dividends",
      "description": "A client's dividend income for a tax year under MTD Income Tax: foreign and special dividends, plain UK dividends, and the directorship information HMRC require where the client is a director of a close company. Three independent HMRC resources, each saved and cleared on its own. Data updates rather than filings with deadlines — HMRC hold the values, a save replaces them in full, and the retrieve re-shows whatever software last sent them."
    },
    {
      "name": "Client - MTD Employments",
      "description": "A client's employment income for a tax year under MTD Income Tax: the employments themselves, the financial details held against each, and the income belonging to no single employment (non-PAYE tips, share schemes, lump sums, deductions). Employments come from two places and what can be done to them differs: one HMRC hold from the employer's RTI submissions cannot be edited or deleted, only ignored, while a custom employment added here can be amended and deleted but never ignored."
    },
    {
      "name": "Client - MTD Foreign Properties",
      "description": "HMRC's register of a client's foreign properties, which exists from tax year 2026-27 onwards. A foreign property income source holds several lets, and HMRC changed how a let is named between two adjacent years: by country code up to 2025-26, by a registered property identifier from 2026-27. That makes the register a precondition for filing rather than a settings page — until a property exists, nothing about the let can be sent. Registering is not idempotent: each call creates a new property."
    },
    {
      "name": "Client - MTD Income Sources",
      "description": "Detail and per-tax-year settings for a client's MTD income sources — the accounting basis, the periods of account, and the late accounting date rule election. These are the writes; to read a year, use Client - MTD Tax Year, which returns every source with its deadlines in one call."
    },
    {
      "name": "Client - MTD ITSA Status",
      "description": "A client's Income Tax Self Assessment status with HMRC for a tax year: whether they are mandated into MTD, volunteered, exempt, on annual filing or dormant. HMRC's answer, read live, so a practice can see whether quarterly updates apply before chasing for them."
    },
    {
      "name": "Client - MTD Losses",
      "description": "A client's losses and loss claims under MTD Income Tax, across HMRC's two shapes. Up to 2025-26 a loss and a claim are each a record with an identifier — created once, amended through that id, deleted, and for carry-sideways claims ordered against each other. From 2026-27 the whole position is one set of figures per income source per year, replaced in full on every save. The amends are POST rather than PUT, mirroring HMRC, who refuse an amend that changes nothing."
    },
    {
      "name": "Client - MTD Quarterly Updates",
      "description": "Prepare and submit Making Tax Digital for Income Tax quarterly updates for a client's income sources. Figures are cumulative from the start of the tax year: a correction is a fresh submission restating the year to date, not an amendment to an earlier quarter. Drafts are saved separately from sending, and submitting records who declared the figures correct. HMRC's obligation status can take up to an hour to reflect a submission."
    },
    {
      "name": "Client - MTD Reliefs",
      "description": "A client's reliefs for a tax year under MTD Income Tax: investment (VCT, EIS, SEIS, community investment), other reliefs (loan interest, maintenance payments, post-cessation losses), foreign tax reliefs, pension contributions and charitable giving. HMRC keep the five as independent resources, so each has its own save and delete; the read returns all five together because the practice reviews them as one job."
    },
    {
      "name": "Client - MTD Savings",
      "description": "A client's savings income for a tax year under MTD Income Tax: the interest reported against each named UK savings account, and the other savings income that belongs to no account (securities interest, foreign interest). Accounts are registered once and live across every tax year while their interest belongs to a single year; HMRC offer no way to delete an account, only to rename it."
    },
    {
      "name": "Client - MTD Tax Liability Adjustments",
      "description": "A client's tax liability adjustments for a tax year under MTD Income Tax: what a carry-back loss claim is worth against the year's bill, and tax already refunded or set off. One HMRC resource per year, replaced in full on every save and cleared by a delete. HMRC support it from 2026-27 only, with no earlier equivalent, and accept a year only once it has ended; an earlier year is refused rather than answered empty. The carry-back claim itself is sent through the losses endpoints first."
    },
    {
      "name": "Client - MTD Tax Return",
      "description": "Reviewing a client's Making Tax Digital Income Tax year and sending their tax return to HMRC. The review is thirty or more HMRC requests behind one call — every income source's obligations, reporting setup, held position and year-end work, all their other income, losses, liability adjustments, HMRC's calculation, and the declaration with whatever is standing in the way — so it is slow the first time a year is opened and fast afterwards. What it reports as standing in the way is advice rather than a gate: HMRC hold the real rules and a practice that disagrees may proceed. The one exception is the declaration, which HMRC require the software itself to enforce. Behind its own permission, separate from quarterly updates, because HMRC allow a supporting agent to file the second and not the first. This filing is not idempotent: a submission whose outcome is unknown is settled by reconciling it against HMRC's own record, never by sending again."
    },
    {
      "name": "Client - MTD Tax Year",
      "description": "A client's Making Tax Digital position for one tax year, assembled from the HMRC resources behind it: the income sources with their quarterly update deadlines and the year's tax return deadline, one source's reporting setup, and everything HMRC hold outside the client's trading income. These replaced a dozen per-resource retrieves — each of those was a browser call, an MTD service call and an HMRC call, and drawing one panel meant enough of them at once that HMRC's rate limiter refused one. Areas HMRC could not be asked about are named on the response and mean 'not asked', never 'nothing held'."
    },
    {
      "name": "Client - Notes",
      "description": "Manage notes associated with specific clients. Supports creating, listing, updating, and deleting client notes with filtering capabilities. Notes can be used for tracking communications, observations, or important client information with timestamp and author tracking."
    },
    {
      "name": "Client - Open Work",
      "description": "Move a client's open work to a role's new holder. When a client's manager, partner or associate, or a service's manager, preparer or reviewer changes, the open tasks and unfinished workflow steps that were assigned from that role stay with the old holder until moved. Preview counts what would move; the reassign moves it. Work someone moved by hand to anyone else is left alone."
    },
    {
      "name": "Client - Pipelines",
      "description": "Manage a client's placements on sales pipelines (kanban cards). Provides CRUD operations for putting a client (typically an Active Prospect) on a pipeline, plus a PATCH endpoint for updating only the stage (used for drag-and-drop). Also serves top-level pipeline card queries that are not scoped to a single client, returning lightweight summary projections for kanban board display with filtering by pipeline code and stage code."
    },
    {
      "name": "Client Portal - Access",
      "description": "Manage portal access for client contacts. Toggle portal access on or off for specific contacts on individual clients. When granting access, a PortalUser record is automatically created if one doesn't exist for the contact. Contacts must have an email address to be granted portal access."
    },
    {
      "name": "Client Portal - Settings",
      "description": "Tenant-level settings for the client portal. Configure the portal title and optional design theme. When no settings exist, the portal title defaults to the practice/tenant name."
    },
    {
      "name": "Client Portal - Users",
      "description": "Manage portal user accounts across the tenant. List all portal users and enable or disable individual portal user accounts. Disabling a portal user prevents them from logging in to the portal without revoking their per-client access grants."
    },
    {
      "name": "Client - Recurring Task Schedules",
      "description": "One client's schedule links on recurring tasks. Every recurring task has a default schedule plus any number of custom schedules; a client linked to a custom schedule gets its occurrences from that schedule instead of the default. These routes read the schedule a client is linked to on a task, link the client to an existing schedule, and revert the client to the default. On the client-filtered recurring-tasks list, each row's schedule is the one that applies to the client. The schedules themselves are managed task-side - see the schedule routes under the Tasks - Recurring tag."
    },
    {
      "name": "Client - Request & Chasing",
      "description": "Settings for client request email templates and automated chasing frequencies. Controls which content blocks are used for document request, approval, confirmation, and form submission emails, plus how often outstanding items are chased."
    },
    {
      "name": "Clients",
      "description": "Comprehensive client management including CRUD operations and task summaries. Supports filtering by manager, partner, status, type, and search terms."
    },
    {
      "name": "Clients - Companies House Enrichment",
      "description": "Enrich clients the practice already holds from Companies House, for the clients a user selected. Preview how many of the selected clients would be enriched and how many are skipped and why, then start it. Starting returns an import job that reports progress. Clients with a type that has no Companies House record, with no company number, or already waiting are skipped."
    },
    {
      "name": "Clients - CSV Export",
      "description": "CSV-based client export with flexible column mapping. Start an export with optional column mappings (reuse saved import mappings or define ad-hoc mappings). If no mapping is provided, all fields are exported with enum names as headers. Filter clients by manager, partner, status, type, service code, or search term. Export jobs are processed asynchronously with a sync-when-fast pattern (waits up to 10 seconds). Poll for status and download the generated CSV via a time-limited URL."
    },
    {
      "name": "Clients - CSV Import",
      "description": "CSV-based client import with flexible column mapping. Upload a CSV file to get a preview with auto-suggested column mappings. Configure mappings using system defaults (Limited Company, Individual) or create custom mappings. Start the import with sync-when-fast pattern (waits up to 10 seconds, returns 201 if completed, 202 if still processing). Supports create-only, update-only, or create-and-update modes with configurable match fields (CompanyNumber, Code, Name, etc.)."
    },
    {
      "name": "Client - Services",
      "description": "Manage billable services associated with specific clients. Provides CRUD operations for linking BillableServices to individual clients, tracking which services are actively provided to each client. This represents the client-specific instances of services from the tenant's service catalog."
    },
    {
      "name": "Client - Sodium Products",
      "description": "A client's accounts in other Sodium products, such as its CIS Manager organisation. Set one up (it is created in the other product and linked to the client) or open it (the signed-in user is made a member there first)."
    },
    {
      "name": "Client - Settings",
      "description": "Tenant-level configuration for client field visibility and behavior. Provides get and update operations for controlling which client fields are enabled and displayed in lists (client manager, partner, associate, internal reference, external links). Includes settings for internal reference uniqueness validation. Requires PracticeDetails permissions to view or modify."
    },
    {
      "name": "Clients - Platform Import",
      "description": "Import clients from third-party platforms (e.g., Xero, QuickBooks) or via direct import with comprehensive data. Includes direct import (create client with all related data in one request), listing available clients from connected platforms, and importing selected or all clients with optional Companies House enrichment. Uses a sync-when-fast pattern for platform imports (waits up to 10 seconds, returns 201 if completed, 202 if still processing)."
    },
    {
      "name": "Clients - Saved Filters",
      "description": "Saved client filter management for personalized client views. Provides CRUD operations for creating, retrieving, updating, and deleting saved client filters. Users can save their preferred client filtering criteria (by manager, partner, associate, status, type, service, etc.) for quick access and reuse. Saved filters are scoped to individual users within a tenant."
    },
    {
      "name": "Clients - Services - Import",
      "description": "CSV-based client service import for bulk-assigning billable services to clients. Upload a native-format CSV to preview what will be created, updated, or left unchanged, then confirm to process. Supports creating new assignments and updating existing ones when values differ. Engager conversion endpoints analyze and convert Engager-format CSVs to native format (fully stateless)."
    },
    {
      "name": "Companies House",
      "description": "Integration with UK Companies House API for retrieving official company information. Provides endpoints to search companies by name or number, get detailed company information, retrieve company officers, fetch key dates for compliance tracking, view filing history with filtering by category, get specific filing details, and download official documents as PDFs."
    },
    {
      "name": "Contacts",
      "description": "Organization-wide contact management across all clients. Provides CRUD operations for contacts that can be associated with multiple clients. Includes an endpoint to retrieve all clients associated with a specific contact, enabling tracking of contact relationships across the tenant's client base."
    },
    {
      "name": "Contacts - CSV Export",
      "description": "Export every contact in the practice to CSV, one row per client link, in the same columns the contacts import reads. Export jobs run asynchronously and wait up to 10 seconds before returning; poll for status and download the file via a time-limited URL."
    },
    {
      "name": "Content Blocks",
      "description": "Reusable content blocks for documents and proposals. Supports CRUD operations with filtering by category and search terms. Content blocks contain HTML content with image support (images are processed for URL transformation). Includes library access for creating content blocks from predefined templates. Used in proposal generation and document templating."
    },
    {
      "name": "CSV Mappings",
      "description": "Manage reusable CSV column mappings for client import and export operations. Mappings define how CSV columns map to client fields and can be saved for reuse across multiple imports or exports. System presets (Limited Company, Individual) are read-only. Tenant-specific mappings can be created, updated, and deleted."
    },
    {
      "name": "Custom Field - Groups",
      "description": "Named groups for organising custom field definitions. Groups can optionally be displayed as their own card on entity detail pages. Supports CRUD operations with filtering by entity type."
    },
    {
      "name": "Custom Fields",
      "description": "Tenant-level custom field definitions for extending entity data. Define custom fields with types (Text, Number, Date, Boolean, Select, MultiSelect) that can be attached to entities like Clients. Supports CRUD operations with filtering by entity type and archived status."
    },
    {
      "name": "Custom Tokens",
      "description": "User-defined reusable tokens for document templates. Custom tokens use {{ Custom.TokenName }} syntax and prompt users to fill in values when generating documents. Each token has a name (the template identifier), optional description (prompt text), and optional default value."
    },
    {
      "name": "Dashboard Links",
      "description": "Links saved on the dashboard, each with an optional title and in an order the user sets. Two lists: the calling user's own, private to them, and one shared across the practice, which every user in it can read and change."
    },
    {
      "name": "Data Form - Categories",
      "description": "Tenant-configurable categories for organizing forms. Provides CRUD operations for creating, retrieving, updating, and deleting form categories."
    },
    {
      "name": "Data Form - Requests",
      "description": "Form requests sent to clients. View submissions and review individual answers (accept or reject per field). Accepted answers apply the submitted value to the client record. Supports auto-accept for forms configured to skip manual review."
    },
    {
      "name": "Data Forms",
      "description": "Custom form management. Create forms with sections and questions, publish them, and send to clients individually or in bulk. Questions can map to client fields, custom fields, or be form-specific."
    },
    {
      "name": "Design Theme - Background Images",
      "description": "Manage background images on design themes for PDF rendering. Each background image can target specific pages (all, first only, all except first) and has configurable positioning (full page, corners, center, or custom coordinates), dimensions, and opacity."
    },
    {
      "name": "Design Themes",
      "description": "Design themes and branding customization for documents and proposals. Provides CRUD operations for themes, plus specialized endpoints to get the default theme, retrieve generated CSS for a specific theme (with optional CSS selector), and get CSS for the default theme. Themes control colors, fonts, and styling for client-facing documents."
    },
    {
      "name": "DirectDebit",
      "description": "Integration with third-party direct debit platforms. Provides endpoints to list payers (customers), create payers, list mandates, and create mandates. The direct debit platform is determined by Tenant.DirectDebitConnectionCode which references a ThirdPartyConnection with DirectDebit capability. A payer can have multiple mandates (e.g., different bank accounts). Create mandate returns authorization URL for customer approval."
    },
    {
      "name": "Document Requests",
      "description": "Tenant-wide list of document requests. Returns a paged list of document requests across all clients with filtering by status and client code. Used by the Requests page to show outstanding document requests."
    },
    {
      "name": "Document Requests - Saved Lists",
      "description": "A practice's saved lists of document request items (kind and text), e.g. a year-end checklist. \"Use a saved list\" copies a list's items into a request or a workflow step; nothing links back, so editing or deleting a list never changes a request. The isActive filter gives the lists offered for use."
    },
    {
      "name": "Documents - Categories",
      "description": "Tenant-configurable document categories for organizing client documents. Provides CRUD operations for creating, retrieving, updating, and deleting custom document categories. Each tenant can define their own document categories with custom names and sort orders."
    },
    {
      "name": "Documents - Filing",
      "description": "Where the practice's client documents are filed: the name of each client's folder in the connected document storage, and for each kind of document (document request uploads, generated documents, form exports and uploads, the signed proposal and engagement letter, the client's portal uploads, saved attachments) its subfolder there and its folder in the client portal, or the portal folder the same as the storage one. Paths may hold Liquid tokens. A document a caller files somewhere explicitly ignores these."
    },
    {
      "name": "Document - Templates",
      "description": "Document templates using Liquid syntax for dynamic content generation. Supports CRUD operations with filtering by template type. Includes library access for using predefined templates, and a render endpoint to generate PDFs from templates with provided data (client, partner, manager, practice, proposal details). Templates support design theme integration for consistent branding."
    },
    {
      "name": "Email - Broadcasts",
      "description": "Ad-hoc mass emails to a filtered set of clients with per-client Liquid token rendering. Provides draft CRUD, a pre-send resolved recipient list with skip warnings (missing contacts, email contact preference), per-client preview, test send to the current user, async sending with progress counters, a per-client delivery log, and cancellation. Recipient selection combines client filters with hand-picked additions and exclusions; recipients are resolved from client contact types, user types (manager/partner/associate/service manager), and static addresses — the same configuration shape as SendEmail workflow steps."
    },
    {
      "name": "Email - Configs",
      "description": "Email configuration management for tenant-specific SMTP or OAuth email providers. Provides CRUD operations for creating, retrieving, updating, and deleting email configurations. Supports multiple configurations per tenant with default/shared management, SMTP settings, and OAuth (Microsoft365/Google) flows. Includes a test endpoint to verify configurations."
    },
    {
      "name": "Email - History",
      "description": "Email history and delivery status tracking. Provides endpoints to view sent emails, check delivery status, and filter by various criteria including custom metadata. Enables tenants to check email delivery status."
    },
    {
      "name": "Email - Mailbox",
      "description": "Read, send, reply to, and manage emails in a tenant's connected mailbox. Only available for OAuth email configurations (Microsoft365/Google) that have ReadEnabled set to true. Conversations provide a thread-grouped view, while Messages provide a flat list. Supports filtering by direction (inbound/outbound) and search by subject or sender. Sending and replying requires SendEnabled to be true on the configuration. Includes OAuth reconnection for expired or misconfigured connections."
    },
    {
      "name": "Email - Settings",
      "description": "Email configuration and settings for tenant email communications. Provides get and update operations for email settings including sender details, email branding (header/footer content blocks, design theme), and other email-related preferences. Requires PracticeDetails permissions to view or modify."
    },
    {
      "name": "Email - Triage",
      "description": "Email triage for connected mailboxes: the practice's editable conversation statuses (which ones mean Done, and whether Done archives the email), each mailbox's triage settings (switched on, default status, default assignee), the people who can be assigned a mailbox's conversations, the status and assignee of many conversations in one change, internal comments with @mentions on a conversation, a summary of a conversation written by hand or by the AI (shown with its triage state), the addresses and domains marked as not a client, and a lookup that classifies addresses as a client's, not a client, the practice's own or unknown."
    },
    {
      "name": "Engagement - Acceptance",
      "description": "Anonymous client-facing endpoints for engagement acceptance workflow. Enables clients to view engagement details without authentication, retrieve CSS for the acceptance page using the configured design theme, download proposal and engagement letter PDFs, and submit acceptance with digital signature and IP address tracking. All endpoints use a GUID-based secure link for access."
    },
    {
      "name": "Engagements",
      "description": "Comprehensive engagement creation, management, and client communication. Provides CRUD operations with filtering by status, client, and search terms. Includes specialized endpoints for uploading and downloading proposal PDFs and letters of engagement (base64-encoded content), sending engagement emails using configured templates with tracking, and retrieving email history for engagements. Engagements capture a snapshot of ClientBillableServices at a point in time."
    },
    {
      "name": "Engagement - Settings",
      "description": "Settings and configuration specific to engagement generation and management. Accessed via the Practice endpoints at /tenants/{tenant}/practice/engagement-settings. Controls default proposal templates, design themes, email templates, and other engagement-specific preferences."
    },
    {
      "name": "External Proposals",
      "description": "Read-only access to proposals from external proposal platforms (e.g., Socket). The platform is determined by Tenant.ProposalConnectionCode which references a ThirdPartyConnection with the Proposals capability."
    },
    {
      "name": "Filing Credits",
      "description": "The practice's prepaid filing credit balance. Submissions to HMRC spend credits at the configured cost per filing type and are refused when the balance cannot cover them; corrections to an already-charged position are free."
    },
    {
      "name": "HMRC Agent Credentials",
      "description": "The practice's sets of HMRC agent details: a Government Gateway login with the ARN, agent codes and agent contact that go with it. One set is the default, which MTD uses for the ARN; letter-based 64-8 requests use the set the practice picks. Passwords are write-only."
    },
    {
      "name": "HMRC Connection",
      "description": "The practice's HMRC connection, used for digital (Making Tax Digital) agent authorisations. Provides the connection status, starts the HMRC consent journey by returning the authorization URL to send the user to, and disconnects the practice from HMRC."
    },
    {
      "name": "Holidays",
      "description": "Tenant-specific custom holidays (e.g., company anniversary, office closure dates). Provides CRUD operations for managing holidays that are specific to your organization. These holidays are combined with bank holidays (based on Working Days region setting) when calculating task scheduling and holiday adjustments."
    },
    {
      "name": "Import Jobs",
      "description": "Asynchronous import job status tracking and management. Provides endpoints to retrieve the current status of import jobs initiated from third-party platforms (e.g., client imports), list all import jobs for a tenant with progress details, and poll for job completion. Import jobs track total items, processed items, success count, failure count, and overall status (queued, in progress, completed, failed, cancelled)."
    },
    {
      "name": "Integrations - Accounting",
      "description": "Integration with third-party accounting platforms. Provides endpoints to list customers from connected accounting systems, retrieve individual customer details, create new customers, and fetch invoices by customer. The accounting platform is determined by the Tenant.AccountingConnectionCode which references a ThirdPartyConnection."
    },
    {
      "name": "Integrations - AML",
      "description": "Integration with third-party Anti-Money Laundering platforms. Provides endpoints to list, get, search, and create clients in connected AML systems, as well as retrieve and start risk assessments for individual AML clients. The AML platform is determined by the Tenant.AmlConnectionCode which references a ThirdPartyConnection."
    },
    {
      "name": "Making Tax Digital",
      "description": "Confirming with HMRC which clients the practice is currently authorised to act for under Making Tax Digital. Lists every MTD authorisation the practice's clients require alongside the status held, what HMRC last confirmed, and whether enough is known about each client to ask HMRC at all."
    },
    {
      "name": "Marketing",
      "description": "Anonymous public marketing endpoints. Brevo-proxied mailing list subscription used by the marketing website."
    },
    {
      "name": "Media Library - Documents",
      "description": "Practice document library — static files (guides, checklists, terms PDFs). Supports multipart upload, metadata updates, deletion (blocked while referenced by workflow email steps), listing with search, and authenticated streaming download. Documents are private and can be pre-specified as attachments on Send Email workflow steps."
    },
    {
      "name": "Media Library - Images",
      "description": "Image asset management for pictures used in emails, documents, and design themes. Supports creating image assets via file upload, retrieving assets with public download URLs, updating asset metadata, deleting assets, and streaming image content with caching support (ETag-based 304 Not Modified responses)."
    },
    {
      "name": "Meeting Notes - Unmatched",
      "description": "Meeting notes imported from a note taker (Granola) that are not on any client's Meetings tab: their attendees matched no client, or more than one. Staff file each on a client (the summary and transcript are fetched then) or ignore it, so it is never offered again. Rows come only from imports: there is no create, update or delete."
    },
    {
      "name": "Messaging",
      "description": "The practice's SMS and WhatsApp messaging with clients and contacts, through the shared Messaging Service. Switching it on finds or creates the practice's messaging account through Account Hub and sets it up in the service; the read derives the status (Unavailable, Off, SettingUp, AwaitingNumber, Active) and lists the numbers the practice sends from. Gated by the Messaging:Enabled switch and, for switching on, the practice's beta features. Received and sent messages are copied in from the service's events into conversations, one per outside number: matched automatically to the contact or client holding the number, or left in an inbox (unrestricted users only) to be matched or dismissed by hand. A client's messages are those of its own conversations and its contacts'."
    },
    {
      "name": "Metadata",
      "description": "System metadata including enums, display names, colors, icons, and configuration options for all system enums. Provides read-only endpoints for retrieving metadata for enums such as client statuses, task statuses, service categories, billing frequencies, permissions, and many others. Also includes third-party platform metadata with capabilities and OAuth configuration details, and the currency/locale whitelists a practice can be configured with."
    },
    {
      "name": "Notifications",
      "description": "The signed-in user's in-app notifications: work assigned to them (tasks and workflow steps) and client responses they were waiting for. A keyset feed with Inbox, Unread and Done views, the unseen and unread counts behind the bell, seen/read/done state changes, and per-type settings to turn each notification off. Every endpoint is scoped to the caller; an item the caller may no longer see is returned redacted."
    },
    {
      "name": "Outbound Webhooks",
      "description": "The practice's webhooks: its own HTTPS URLs that receive a signed POST (Standard Webhooks) when a client is created, updated or archived, or a task is created or completed. Delivered, signed, retried and logged by the shared Webhook Service; these routes pass through to it. The practice's first webhook sets it up in the service through Account Hub. Each webhook picks its event types from the catalogue at /metadata/outbound-webhook-event-types (or * for everything) and full or thin bodies; its signing secret is answered only by the create and a rotation. The delivery log shows every event sent, with its body and attempts, and a failed delivery can be sent again. Outbound Webhooks ViewAll to read, Create to add, Delete to remove and Update for the rest (Pro only), so the practice's API key can manage them. Gated by the Webhooks:Enabled switch (409 while off). Not the inbound webhooks under /webhooks."
    },
    {
      "name": "Pipeline - Intake Tasks",
      "description": "Templates for intake tasks that are created automatically when a client (typically an Active Prospect) is added to a pipeline. Each template defines the task name, due-date offset from the card's start date, assignment, optional workflow, category, and checklist. The pipeline sibling of Service - Onboarding Tasks."
    },
    {
      "name": "Pinned Notes",
      "description": "Cross-entity read of the client and task notes pinned to the dashboard (PinnedLevel 3). Pinning itself happens through the ordinary client-note and task-note update endpoints; this surface only lists what has been pinned, filtered by the caller's Clients/Tasks view permissions and client visibility restrictions."
    },
    {
      "name": "Pipelines",
      "description": "Tenant-level sales pipeline catalog management. Pipelines are prospect funnels with user-defined kanban stages and no pricing/proposal concerns. Provides CRUD operations with filtering by archived status, stages, kanban visibility, and search, plus library access for importing pre-built pipelines."
    },
    {
      "name": "Practice Note",
      "description": "The practice's single shared free-text note. One per tenant, readable and writable by every user in it, with no permission gate. GET returns empty text until somebody writes something; PUT saves against the version being edited (ExpectedUpdatedDate) and comes back with saved=false, untouched, when somebody else saved first."
    },
    {
      "name": "Practice",
      "description": "Practice-level settings and configuration for the tenant. Includes endpoints to get and update practice details (firm name, address, contact information, professional body memberships, etc.). Requires PracticeDetails permissions to view or modify."
    },
    {
      "name": "Professional Clearance",
      "description": "Professional clearance letter management for client transitions. Provides CRUD operations for professional clearance request items (document and information requests sent to previous accountants), settings configuration for PCL emails, client-specific endpoints to retrieve applicable PCR items (filtered by billable services and including global items), and sending professional clearance letters via email with template variable substitution."
    },
    {
      "name": "Reports",
      "description": "Curated, typed, read-only reports over the tenant's operational data. Each report accepts a preset or custom date range plus entity filters (service, client, user, team, category) and returns headline KPIs with breakdown rows carrying entity codes for drill-down, plus a synchronous CSV export sibling. Report #1 is Service Delivery Turnaround: how fast tasks complete versus their due and statutory dates, grouped by service, client, assignee, or month, with a per-service workflow-step bottleneck drill-down splitting client-wait time from internal time. Requires Reports permissions; CSV export requires Export."
    },
    {
      "name": "Requests",
      "description": "Cross-cutting summary of the Requests page: one outstanding count per tab (steps ready to send, pending scheduled sends, forms awaiting a response, document approvals pending, document requests open and submitted, open confirmations). Each count is scoped by the caller's own permissions and is null where the role cannot read that area."
    },
    {
      "name": "Revenue Ranges",
      "description": "Tenant-configurable revenue ranges for client classification and pricing. Provides CRUD operations for creating, retrieving, updating, and deleting custom revenue ranges. Revenue ranges are used to categorize clients by annual revenue and enable revenue-based pricing overrides for billable services. Each tenant can define their own revenue ranges with custom names and sort orders."
    },
    {
      "name": "Roles",
      "description": "Custom (tenant-defined) roles granting per-entity capability sets. Capabilities are independent flags — granting Import does not imply Delete; Admin on an entity grants everything on it. Create and update cap the requested grants at the capabilities the requesting user holds, so a role manager can never hand out more access than they have. Deletion is blocked while users are assigned to the role. The built-in system roles (Admin, Standard User, Viewer) are code-defined and not managed here."
    },
    {
      "name": "Sales Pipeline - Settings",
      "description": "Tenant-level settings for the Sales Pipeline feature. A tenant singleton exposing whether the feature is enabled — when off (the default) the pipeline UI is hidden and no pipeline automations run; when on, Active Prospects are also included in the tenant's billable client count."
    },
    {
      "name": "Scheduled Sends",
      "description": "Deferred outbound sends: emails, replies, workflow step sends, document requests, data forms, document approvals and broadcasts scheduled for a later dispatch time. Rows are created by passing scheduledAt to the normal send endpoints; these endpoints list, reschedule, edit, dispatch-now and cancel them. Used by the Requests page Scheduled tab."
    },
    {
      "name": "Security Settings",
      "description": "Tenant-level security settings. A tenant singleton exposing whether every user must complete multi-factor authentication to use the web app, and whether API keys may access the tenant. Both are enforced on every request; the MFA requirement is also pushed to the identity provider so users are challenged at login."
    },
    {
      "name": "Service - Categories",
      "description": "Tenant-configurable categories for grouping billable services. Provides CRUD operations for creating, retrieving, updating, and deleting service categories. Every tenant sees a shared set of built-in categories plus any it creates itself. A tenant can rename, reorder and recolour a built-in category - the change applies only to that tenant and leaves existing services attached to it - but built-in categories cannot be deleted."
    },
    {
      "name": "Service - Onboarding Tasks",
      "description": "Templates for one-off tasks that are automatically created when a client takes on a billable service. When a ClientBillableService becomes Active, the system creates TaskItems from matching OnboardingTaskTemplates. Each template belongs to a specific BillableService and defines task details like name, description, due date offset from service start, assignment rules, and optional workflow."
    },
    {
      "name": "Service - Packages",
      "description": "Service package management for bundling multiple billable services together. Provides CRUD operations for creating, retrieving, updating, and deleting service packages. Each package contains a list of billable services with pre-configured billing frequency, pricing options, and pre-answered pricing factors. Packages can be applied to clients in bulk, creating multiple ClientBillableService records at once with the pre-configured settings."
    },
    {
      "name": "Services",
      "description": "Tenant-level billable services catalog management. Provides CRUD operations with filtering by category, client type, archived status, and search terms. Includes library access for creating services from templates, AI-powered service generation from service names (generates description and pricing), pricing factor generation for existing services, and creating services from library templates with optional property overrides."
    },
    {
      "name": "Services - Import",
      "description": "CSV-based import and export of the billable services catalog. Auto-detects the file format: native Sodium exports (rows with a matching Code update the existing service) or Ignition services exports (create-only). Analyze returns editable preview rows; import re-uploads the file with the user's selections and creates/updates services plus deduplicated Service Terms content blocks. Export produces the native format including terms HTML, doubling as the import template. All endpoints are stateless."
    },
    {
      "name": "Sodium Apps",
      "description": "The practice's connections to the other Sodium products (Settings > Sodium Apps). Read whether the practice is connected to CIS Manager, connect it (its CIS Manager practice is set up and the signed-in user joins it, no client organisation is created), and the CIS Manager settings: the email templates the CIS Manager client workflow steps send with."
    },
    {
      "name": "Subscription",
      "description": "Tenant subscription management. View the current subscription, subscription history, change packages, and cancel subscriptions. Cancelling ends the current subscription immediately and marks the tenant as cancelled. Choosing a new plan via PUT clears the cancellation. The pricing tier is automatically determined from the tenant's active client count."
    },
    {
      "name": "Subscription - Billing",
      "description": "Billing account management for tenant subscriptions. Create and manage billing accounts, set up Direct Debit mandates via GoCardless, and view invoices. Only tenant administrators can access billing endpoints."
    },
    {
      "name": "Subscription - Discounts",
      "description": "Discount code management for tenant subscriptions. Redeem promotional discount codes to receive percentage-based billing discounts, view the active discount, or remove it to apply a different code. Discounts are applied automatically during monthly billing."
    },
    {
      "name": "Subscription - Packages",
      "description": "Public endpoints for listing packages and their pricing tiers. Packages define which feature modules are available, and each package has its own set of pricing tiers."
    },
    {
      "name": "Task - Emails",
      "description": "Returns email conversations that have been explicitly linked to a task."
    },
    {
      "name": "Task - Notes",
      "description": "Manage notes associated with specific tasks. Supports creating, listing, updating, and deleting task notes. Notes can be pinned for priority visibility (PinnedLevel > 0) and include author tracking and timestamps. Useful for collaboration and tracking important information related to tasks."
    },
    {
      "name": "Tasks",
      "description": "Comprehensive task management including creation, assignment, tracking, and filtering. Supports listing tasks with flexible date range handling, overdue filtering, agenda mode (including workflow steps), and filtering by client, user, recurring task, category, status, and saved filters. Can optionally include projected (virtual) tasks alongside materialized tasks. Provides full CRUD operations plus bulk update (status and/or assigned user) with multi-tenant scoping."
    },
    {
      "name": "Tasks - Categories",
      "description": "Tenant-configurable task categories for organizing and classifying tasks. Provides CRUD operations for creating, retrieving, updating, and deleting custom task categories. Each tenant can define their own task categories with custom names and sort orders to organize tasks according to their specific workflow and organizational needs."
    },
    {
      "name": "Tasks - Focus Config",
      "description": "Per-user configuration for the Task Focus Panel sidebar. Provides GET (auto-creates empty default) and PUT (upsert) operations for managing which saved task filters appear in the focus panel. Each item references a user's own saved task filter with optional label, sort order, and color. One config per user per tenant."
    },
    {
      "name": "Tasks - Import",
      "description": "Task CSV import and export. Analyze parses a native-format task CSV and returns preview rows with client/user/team/category names resolved and unmatched values flagged; import re-uploads the analyzed file with the user's selections and creates or updates tasks (matched by Code), turning a row's Notes text into a task note. Export downloads all tasks as a native-format CSV that doubles as the import template and supports update-by-code round-trips. Analyze and import are stateless — nothing is persisted between the two calls."
    },
    {
      "name": "Tasks - Projected",
      "description": "Projected (virtual) task items generated from recurring tasks that haven't been materialized yet. Provides endpoints to list projected tasks within date ranges with filtering, retrieve individual projected tasks by composite code (format: proj-{recurringTaskCode}-{clientCode}-{yyyyMMdd}), materialize projected tasks into real database records, and retrieve workflow groups for projected tasks with resolved assignments. Projected tasks are excluded from results once materialized."
    },
    {
      "name": "Tasks - Recurring",
      "description": "Recurring task templates and scheduling for automated task generation. Supports CRUD operations with filtering capabilities, plus endpoints to manage client associations (get/update specific clients for a recurring task) and service associations (get/update billable services that trigger task generation). Recurring tasks generate projected tasks based on configured recurrence patterns."
    },
    {
      "name": "Tasks - Saved Filters",
      "description": "Saved task filter management for personalized task views. Provides CRUD operations for creating, retrieving, updating, and deleting saved task filters. Users can save their preferred task filtering criteria (by client, status, date range, assigned user, etc.) for quick access and reuse. Saved filters are scoped to individual users within a tenant."
    },
    {
      "name": "Tasks - Settings",
      "description": "Practice-wide task settings. A tenant singleton, readable by every user in the practice and updated by those who manage practice details. Holds whether condition-omitted workflow steps are hidden on a task."
    },
    {
      "name": "Tasks - Templates",
      "description": "One-off task templates: pre-defined task shapes (description, checklist, optional workflow, category, assignment rule, due-date offset) that users turn into real tasks for a chosen client on demand. Templates never create tasks automatically. Supports CRUD operations plus library browse, import (cascading referenced workflows and categories), and revert-to-library."
    },
    {
      "name": "Task - Workflow Notes",
      "description": "Manage notes associated with specific workflow steps within tasks. Supports creating, listing, updating, and deleting step-level notes. Notes can be pinned for priority visibility (PinnedLevel > 0) and include author tracking and timestamps. Useful for documenting work done on specific workflow steps."
    },
    {
      "name": "Task - Workflows",
      "description": "Task workflow progress tracking and step management for individual tasks. Provides endpoints to retrieve workflow groups with steps and progress statistics, initialize or reset workflow steps for a task (clears existing progress), remove workflow assignments from tasks, and update individual workflow steps (status, assignment, email configuration, time tracking). Supports customizing email recipients and execution mode for SendEmail steps before execution. All operations validate dependencies and maintain workflow integrity."
    },
    {
      "name": "Tenants",
      "description": "Multi-tenant organization management and configuration. Provides endpoints to create new tenants with package assignment and invite code validation, list all tenants the authenticated user belongs to, retrieve tenant details by code, get the current user's role and permissions within a tenant, update tenant information, and delete tenants (with validation to prevent deletion if clients exist). Tenants represent separate organizations within the multi-tenant system."
    },
    {
      "name": "Text Broadcasts",
      "description": "Bulk texts: one SMS to each chosen contact's mobile at a filtered set of clients, sent from the practice's own number, with per-client and per-recipient Liquid token rendering. Provides draft CRUD, an audience summary, a pre-send recipient list with the reason each person is missed (no mobile, contact preference, the do-not-text list, a number shared with another client), repeated numbers, a per-client preview and a cost estimate in credits. Clients are chosen as for a bulk email."
    },
    {
      "name": "Third-Party Connections",
      "description": "OAuth connections and integrations to third-party platforms (accounting systems, practice management tools, etc.). Provides CRUD operations for managing connections, an anonymous OAuth callback endpoint for handling authorization code exchanges, and an endpoint to set organization IDs for connections in Initialising status to activate them. Supports platforms like QuickBooks, Xero, and others with OAuth2 authentication."
    },
    {
      "name": "Time Tracking",
      "description": "Time entries recorded by team members, optionally linked to a client and/or task. Supports CRUD operations with filtering by user, client, task, date range, billable flag, and billed state. Billable entries carry an hourly rate snapshot and can later be converted into client billing line items."
    },
    {
      "name": "Time Tracking - Import",
      "description": "Time entry CSV import for timesheets exported from other tools (Clockify, Toggl, spreadsheets). Analyze parses the file, resolves its columns by name, and returns the rows for review plus the distinct team member and client names with suggested matches; import re-uploads the analyzed file with the selected rows and the name mappings and creates one time entry per row through the standard create path (rates stamped, link requirement enforced). Both calls are stateless."
    },
    {
      "name": "Time Tracking - Rates",
      "description": "The practice's charge-out and cost rates for a type of work — a task category or a service — kept as date-effective entries. They override team members' own rates and the practice defaults for time logged against that type of work; a team member's own rates by type of work (under /users/{userCode}/work-type-rates) override these in turn. The time recording setting workTypeRatePrecedence decides whether the category or the service wins when both apply."
    },
    {
      "name": "Time Tracking - Settings",
      "description": "Tenant-level settings for time recording. Enable or disable time tracking (hides all time tracking UI when off), require entries to be linked to a client or task, and set the practice default hourly rate."
    },
    {
      "name": "Time Tracking - Time Off",
      "description": "Team members' holiday, sickness and other leave, as date ranges of whole or part days. Each day off takes the member's expected hours down, on Team Time, the Time calendar and the Capacity report. Everyone manages their own; anyone else's needs the Time Off permission, which only admins hold by default."
    },
    {
      "name": "Time Tracking - Timer",
      "description": "The calling user's live timer — at most one per user. Start or update it, read it (returns null when nothing is running), or discard it. Stopping is client-side: the elapsed time pre-fills a time entry and the timer is discarded once that entry is saved."
    },
    {
      "name": "Time Tracking - Write-off Reasons",
      "description": "Tenant-configurable reasons for writing time off (or on) against a fee: Quoted fixed fee, Overrun, Goodwill, Client dispute, Training / junior time, Other by default. A reason already used on an allocation cannot be deleted; deactivate it instead."
    },
    {
      "name": "Time Tracking - Working Patterns",
      "description": "Named working weeks team members can be put on — \"Full time\", \"Part time (Mon/Wed/Fri)\" — holding the minutes expected on each day. One pattern per tenant is the default, used for every member not put on a specific one. The Team Time report measures logged hours against them."
    },
    {
      "name": "User - Account",
      "description": "User account management endpoints including retrieving unused invite codes for the authenticated user. These endpoints help users manage their invite code allocations for creating new tenants."
    },
    {
      "name": "User - Invitations",
      "description": "User invitation workflow for adding users to tenants. Provides endpoints to list pending invitations for the authenticated user, accept or decline invitations (validates email verification), and send invitation emails to users. Invitations include token-based security, email verification requirements, and status tracking (pending, accepted, declined)."
    },
    {
      "name": "Users",
      "description": "User management and authentication within the application. Provides endpoints to get the current authenticated user's profile, verify email addresses using verification keys from email links (with token expiration handling), and resend verification emails to authenticated users. Also includes tenant-scoped user management (CRUD operations) accessed via /tenants/{tenant}/users for managing users within specific tenants."
    },
    {
      "name": "User - Notes",
      "description": "The calling user's own free-text notes, private to them. A user can keep as many as they like; every operation resolves the note through the calling user, so one user can never read or change another's note even with its code."
    },
    {
      "name": "User - Teams",
      "description": "Team management for group task assignment. Provides CRUD operations for creating, retrieving, updating, and deleting teams. Includes member management endpoints for adding and removing users from teams, and a 'my teams' endpoint for listing the current user's teams. Teams enable work to be assigned to a group rather than an individual, allowing team members to pick tasks from a shared queue."
    },
    {
      "name": "User - View Preferences",
      "description": "Per-user view preferences for storing UI configuration as JSON. Each user can have one preference per view key (e.g. \"dashboard\" for dashboard layout). GET auto-creates an empty default; PUT creates or updates the configuration."
    },
    {
      "name": "Webhooks",
      "description": "Inbound webhook receipt from third-party platforms (e.g. FuseSign e-signature events). Anonymous by necessity — the opaque connection token in the URL identifies the tenant, and each provider's signature header verifies origin. Deliveries are persisted to an inbox and processed asynchronously; 200 means durably received, including redeliveries of an event already held."
    },
    {
      "name": "Workflows",
      "description": "Reusable workflow definitions and templates for task automation. Provides CRUD operations for creating, retrieving, updating, and deleting workflow templates. Includes library access for browsing predefined templates, importing workflows from the library, and AI-powered workflow generation from a name and description. Workflows define sequences of steps, dependencies, assignments, and completion requirements that can be applied to tasks to standardize processes across the organization."
    },
    {
      "name": "Workflow Steps - Pending",
      "description": "Manual-mode outbound workflow steps that are ready to send. Dependencies are met and a user needs to review and trigger the send. Used by the Requests page Ready to Send tab. Steps with a pending scheduled send are excluded until the schedule dispatches, fails or is cancelled."
    },
    {
      "name": "Working Days",
      "description": "Configure working days, holidays, and task scheduling adjustments. Provides get and update operations for bank holiday region (England, Wales, Scotland, Northern Ireland) and default holiday adjustment behavior when tasks fall on non-working days. Also includes an endpoint to list bank holidays for the configured region."
    }
  ]
}