{
  "openapi": "3.1.0",
  "info": {
    "title": "Basenet Public API",
    "version": "1.0.0",
    "description": "Versioned public REST API for the Basenet legal practice platform. Versioning policy: the /api/v1 path prefix is the major version; breaking changes ship under /api/v2 with v1 supported through a published deprecation window. Auth uses scoped Bearer tokens; every request is permission-filtered by the same engine that guards the UI. Rate limits are per token. Money is integer cents; timestamps are ISO-8601 UTC."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Scoped API token (bnx_…). Required scopes are noted per operation."
      }
    },
    "schemas": {},
    "parameters": {}
  },
  "paths": {
    "/api/v1/matters": {
      "get": {
        "tags": [
          "matters"
        ],
        "summary": "List matters (scope matters:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "number": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "flavor": {
                            "type": "string"
                          },
                          "practiceArea": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "departmentId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "accessLevelId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "solicitorResponsibleRelationId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "startDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "closedDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "legalAid": {
                            "type": "object",
                            "properties": {
                              "present": {
                                "type": "boolean"
                              },
                              "stage": {
                                "type": "string",
                                "enum": [
                                  "none",
                                  "requested",
                                  "assigned"
                                ]
                              },
                              "hourlyFrom": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "continuesAsHoursMatter": {
                                "type": "boolean",
                                "description": "Deprecated: derived as hourlyFrom !== null. Prefer hourlyFrom for the dated switch."
                              },
                              "filter": {
                                "type": "string",
                                "enum": [
                                  "yes",
                                  "no",
                                  "hours"
                                ]
                              }
                            },
                            "required": [
                              "present",
                              "stage",
                              "hourlyFrom",
                              "continuesAsHoursMatter",
                              "filter"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "number",
                          "name",
                          "status",
                          "flavor",
                          "practiceArea",
                          "departmentId",
                          "accessLevelId",
                          "solicitorResponsibleRelationId",
                          "startDate",
                          "closedDate",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "skip": {
                      "type": "integer"
                    },
                    "top": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "skip",
                    "top"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "matters"
        ],
        "summary": "Create a matter (scope matters:write)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "clientRelationId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "departmentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "practiceArea": {
                    "type": "string"
                  },
                  "flavor": {
                    "type": "string",
                    "enum": [
                      "legal",
                      "debt_collection",
                      "insolvency",
                      "roll",
                      "tax_law",
                      "general"
                    ]
                  },
                  "responsibleRelationId": {
                    "type": "string"
                  },
                  "acknowledgeConflicts": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "name",
                  "clientRelationId",
                  "departmentId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created resource",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "matter": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "number": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "flavor": {
                          "type": "string"
                        },
                        "practiceArea": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "departmentId": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "accessLevelId": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "solicitorResponsibleRelationId": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "startDate": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "closedDate": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "legalAid": {
                          "type": "object",
                          "properties": {
                            "present": {
                              "type": "boolean"
                            },
                            "stage": {
                              "type": "string",
                              "enum": [
                                "none",
                                "requested",
                                "assigned"
                              ]
                            },
                            "hourlyFrom": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "continuesAsHoursMatter": {
                              "type": "boolean",
                              "description": "Deprecated: derived as hourlyFrom !== null. Prefer hourlyFrom for the dated switch."
                            },
                            "filter": {
                              "type": "string",
                              "enum": [
                                "yes",
                                "no",
                                "hours"
                              ]
                            }
                          },
                          "required": [
                            "present",
                            "stage",
                            "hourlyFrom",
                            "continuesAsHoursMatter",
                            "filter"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "number",
                        "name",
                        "status",
                        "flavor",
                        "practiceArea",
                        "departmentId",
                        "accessLevelId",
                        "solicitorResponsibleRelationId",
                        "startDate",
                        "closedDate",
                        "createdAt",
                        "updatedAt"
                      ]
                    },
                    "conflicts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "matterId": {
                            "type": "string"
                          },
                          "matterNumber": {
                            "type": "string"
                          },
                          "matterName": {
                            "type": "string"
                          },
                          "relationId": {
                            "type": "string"
                          },
                          "relationName": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "matterId",
                          "matterNumber",
                          "matterName",
                          "relationId",
                          "relationName",
                          "role"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/matters/{id}": {
      "get": {
        "tags": [
          "matters"
        ],
        "summary": "Get a matter (scope matters:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Single resource",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "number": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "flavor": {
                      "type": "string"
                    },
                    "practiceArea": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "departmentId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "accessLevelId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "solicitorResponsibleRelationId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "startDate": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "closedDate": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "legalAid": {
                      "type": "object",
                      "properties": {
                        "present": {
                          "type": "boolean"
                        },
                        "stage": {
                          "type": "string",
                          "enum": [
                            "none",
                            "requested",
                            "assigned"
                          ]
                        },
                        "hourlyFrom": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "continuesAsHoursMatter": {
                          "type": "boolean",
                          "description": "Deprecated: derived as hourlyFrom !== null. Prefer hourlyFrom for the dated switch."
                        },
                        "filter": {
                          "type": "string",
                          "enum": [
                            "yes",
                            "no",
                            "hours"
                          ]
                        }
                      },
                      "required": [
                        "present",
                        "stage",
                        "hourlyFrom",
                        "continuesAsHoursMatter",
                        "filter"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "number",
                    "name",
                    "status",
                    "flavor",
                    "practiceArea",
                    "departmentId",
                    "accessLevelId",
                    "solicitorResponsibleRelationId",
                    "startDate",
                    "closedDate",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/matters/{id}/legal-aid": {
      "get": {
        "tags": [
          "matters",
          "billing"
        ],
        "summary": "Get legal-aid (toevoeging) details for a matter (scope billing:read). Returns present=false when no row exists.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Legal-aid record or present=false",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "present": {
                      "type": "boolean"
                    },
                    "matterId": {
                      "type": "string"
                    },
                    "id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "boardRelationId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "legalAidNumber": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "type": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "caseCategory": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "points": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "basicChargeCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "travelTimeCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "travelCostCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "standardCostsCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "ownContributionCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "ownContributionInvoicedCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "legalServicesReimbursementCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "budgetCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "dateRequested": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "dateAssigned": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hourlyFrom": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "continuesAsHoursMatter": {
                      "type": "boolean",
                      "description": "Deprecated: derived as hourlyFrom !== null. Prefer hourlyFrom for the dated switch."
                    },
                    "createdAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "updatedAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "present",
                    "matterId",
                    "id",
                    "boardRelationId",
                    "legalAidNumber",
                    "note",
                    "type",
                    "caseCategory",
                    "points",
                    "basicChargeCents",
                    "travelTimeCents",
                    "travelCostCents",
                    "standardCostsCents",
                    "ownContributionCents",
                    "ownContributionInvoicedCents",
                    "legalServicesReimbursementCents",
                    "budgetCents",
                    "dateRequested",
                    "dateAssigned",
                    "hourlyFrom",
                    "continuesAsHoursMatter",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "matters",
          "billing"
        ],
        "summary": "Create or update legal-aid (toevoeging) details for a matter (scope matters:write; billing update required).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "boardRelationId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "legalAidNumber": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "type": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "caseCategory": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "basicChargeCents": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "travelTimeCents": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "travelCostCents": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "standardCostsCents": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "ownContributionCents": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "legalServicesReimbursementCents": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "dateRequested": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "dateAssigned": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "hourlyFrom": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "requireType": {
                    "type": "boolean"
                  },
                  "clearLegacyToevoeging": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "hourlyFrom"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved legal-aid record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "present": {
                      "type": "boolean"
                    },
                    "matterId": {
                      "type": "string"
                    },
                    "id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "boardRelationId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "legalAidNumber": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "type": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "caseCategory": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "points": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "basicChargeCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "travelTimeCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "travelCostCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "standardCostsCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "ownContributionCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "ownContributionInvoicedCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "legalServicesReimbursementCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "budgetCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "dateRequested": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "dateAssigned": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hourlyFrom": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "continuesAsHoursMatter": {
                      "type": "boolean",
                      "description": "Deprecated: derived as hourlyFrom !== null. Prefer hourlyFrom for the dated switch."
                    },
                    "createdAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "updatedAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "present",
                    "matterId",
                    "id",
                    "boardRelationId",
                    "legalAidNumber",
                    "note",
                    "type",
                    "caseCategory",
                    "points",
                    "basicChargeCents",
                    "travelTimeCents",
                    "travelCostCents",
                    "standardCostsCents",
                    "ownContributionCents",
                    "ownContributionInvoicedCents",
                    "legalServicesReimbursementCents",
                    "budgetCents",
                    "dateRequested",
                    "dateAssigned",
                    "hourlyFrom",
                    "continuesAsHoursMatter",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/relations": {
      "get": {
        "tags": [
          "relations"
        ],
        "summary": "List relations (scope relations:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "systemKind": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "systemCode": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "companyName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "firstName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "lastName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "email": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "phone": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "departmentId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "accessLevelId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "active": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "kind",
                          "systemKind",
                          "systemCode",
                          "companyName",
                          "firstName",
                          "lastName",
                          "email",
                          "phone",
                          "departmentId",
                          "accessLevelId",
                          "active",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "skip": {
                      "type": "integer"
                    },
                    "top": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "skip",
                    "top"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "relations"
        ],
        "summary": "Create a relation (scope relations:write). Runs the advisory duplicate check; send confirmDuplicates=true to create anyway after reviewing matches (BLI-1408).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "company",
                      "contact",
                      "individual",
                      "employee",
                      "court",
                      "prosecutor"
                    ]
                  },
                  "departmentId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "companyName": {
                    "type": "string"
                  },
                  "firstName": {
                    "type": "string"
                  },
                  "lastName": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "kvkNumber": {
                    "type": "string"
                  },
                  "confirmDuplicates": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "kind",
                  "departmentId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created resource",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "systemKind": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "systemCode": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "companyName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "firstName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "lastName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "email": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "phone": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "departmentId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "accessLevelId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "active": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "kind",
                    "systemKind",
                    "systemCode",
                    "companyName",
                    "firstName",
                    "lastName",
                    "email",
                    "phone",
                    "departmentId",
                    "accessLevelId",
                    "active",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Duplicate relation matches found; resubmit with confirmDuplicates=true to create anyway",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "duplicates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string",
                            "enum": [
                              "kvk",
                              "email",
                              "name_birthday",
                              "company_name"
                            ]
                          },
                          "score": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "reason",
                          "score"
                        ]
                      },
                      "minItems": 1
                    }
                  },
                  "required": [
                    "duplicates"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/relations/{id}": {
      "get": {
        "tags": [
          "relations"
        ],
        "summary": "Get a relation (scope relations:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Single resource",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "systemKind": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "systemCode": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "companyName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "firstName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "lastName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "email": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "phone": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "departmentId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "accessLevelId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "active": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "kind",
                    "systemKind",
                    "systemCode",
                    "companyName",
                    "firstName",
                    "lastName",
                    "email",
                    "phone",
                    "departmentId",
                    "accessLevelId",
                    "active",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/documents": {
      "get": {
        "tags": [
          "documents"
        ],
        "summary": "List document metadata (scope documents:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": false,
            "name": "relationId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "matterId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "relationId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "type": {
                            "type": "string"
                          },
                          "subject": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "correspondenceNumber": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "contentType": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "sizeBytes": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "latestChecksum": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "departmentId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "accessLevelId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "matterId",
                          "relationId",
                          "type",
                          "subject",
                          "correspondenceNumber",
                          "contentType",
                          "sizeBytes",
                          "latestChecksum",
                          "departmentId",
                          "accessLevelId",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "skip": {
                      "type": "integer"
                    },
                    "top": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "skip",
                    "top"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/documents/export": {
      "get": {
        "tags": [
          "documents"
        ],
        "summary": "Export permission-filtered document metadata CSV (scope documents:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": false,
            "name": "relationId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "CSV metadata export (capped with total/truncated response headers)",
            "headers": {
              "content-disposition": {
                "schema": {
                  "type": "string",
                  "description": "Attachment filename for the CSV export."
                },
                "required": true,
                "description": "Attachment filename for the CSV export."
              },
              "x-blinqx-export-total": {
                "schema": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Total permitted records before the export cap is applied."
                },
                "required": true,
                "description": "Total permitted records before the export cap is applied."
              },
              "x-blinqx-export-truncated": {
                "schema": {
                  "type": "boolean",
                  "description": "Whether the export cap omitted permitted records."
                },
                "required": true,
                "description": "Whether the export cap omitted permitted records."
              }
            },
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/documents/{id}/content": {
      "get": {
        "tags": [
          "documents"
        ],
        "summary": "Download document content (scope documents:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Binary content stream",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/hours": {
      "get": {
        "tags": [
          "hours"
        ],
        "summary": "List hour entries (scope hours:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "matterId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "employeeUserId": {
                            "type": "string"
                          },
                          "date": {
                            "type": "string"
                          },
                          "workedHours": {
                            "type": "number"
                          },
                          "billableHours": {
                            "type": "number"
                          },
                          "timeClass": {
                            "type": "string"
                          },
                          "activityCode": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "timekeepingGroup": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "description": {
                            "type": "string"
                          },
                          "rateCents": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "rateSource": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "rateResolutionReason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "invoiceId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "matterId",
                          "employeeUserId",
                          "date",
                          "workedHours",
                          "billableHours",
                          "timeClass",
                          "activityCode",
                          "timekeepingGroup",
                          "description",
                          "rateCents",
                          "rateSource",
                          "rateResolutionReason",
                          "invoiceId",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "skip": {
                      "type": "integer"
                    },
                    "top": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "skip",
                    "top"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "hours"
        ],
        "summary": "Create an hour entry (scope hours:write)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "matterId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "date": {
                    "type": "string",
                    "minLength": 1
                  },
                  "workedHours": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "description": {
                    "type": "string",
                    "minLength": 1
                  },
                  "timeClass": {
                    "type": "string",
                    "enum": [
                      "billable",
                      "internal",
                      "non_billable"
                    ]
                  },
                  "activityCode": {
                    "type": "string"
                  }
                },
                "required": [
                  "matterId",
                  "date",
                  "workedHours",
                  "description"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created resource",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "matterId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "employeeUserId": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string"
                    },
                    "workedHours": {
                      "type": "number"
                    },
                    "billableHours": {
                      "type": "number"
                    },
                    "timeClass": {
                      "type": "string"
                    },
                    "activityCode": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "timekeepingGroup": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "description": {
                      "type": "string"
                    },
                    "rateCents": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "rateSource": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "rateResolutionReason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "invoiceId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "matterId",
                    "employeeUserId",
                    "date",
                    "workedHours",
                    "billableHours",
                    "timeClass",
                    "activityCode",
                    "timekeepingGroup",
                    "description",
                    "rateCents",
                    "rateSource",
                    "rateResolutionReason",
                    "invoiceId",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tasks": {
      "get": {
        "tags": [
          "tasks"
        ],
        "summary": "List tasks (scope tasks:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "matterId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "assigneeRelationId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "taskType": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "startDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "dueDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "doneDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "escalationDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "recurrenceRule": {
                            "type": [
                              "object",
                              "null"
                            ],
                            "properties": {
                              "freq": {
                                "type": "string",
                                "enum": [
                                  "daily",
                                  "weekly",
                                  "monthly"
                                ]
                              },
                              "interval": {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              "until": {
                                "type": "string",
                                "format": "date"
                              },
                              "count": {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              }
                            },
                            "required": [
                              "freq",
                              "interval"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "matterId",
                          "assigneeRelationId",
                          "taskType",
                          "status",
                          "description",
                          "startDate",
                          "dueDate",
                          "doneDate",
                          "escalationDate",
                          "recurrenceRule",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "skip": {
                      "type": "integer"
                    },
                    "top": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "skip",
                    "top"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "tasks"
        ],
        "summary": "Create a task (scope tasks:write)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string",
                    "minLength": 1
                  },
                  "matterId": {
                    "type": "string"
                  },
                  "assigneeRelationId": {
                    "type": "string"
                  },
                  "startDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "string",
                        "format": "date-time"
                      }
                    ]
                  },
                  "dueDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "string",
                        "format": "date-time"
                      }
                    ]
                  },
                  "escalationDate": {
                    "type": "string",
                    "format": "date"
                  },
                  "recurrenceRule": {
                    "type": "object",
                    "properties": {
                      "freq": {
                        "type": "string",
                        "enum": [
                          "daily",
                          "weekly",
                          "monthly"
                        ]
                      },
                      "interval": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      "until": {
                        "type": "string",
                        "format": "date"
                      },
                      "count": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      }
                    },
                    "required": [
                      "freq",
                      "interval"
                    ]
                  },
                  "taskType": {
                    "type": "string"
                  }
                },
                "required": [
                  "description"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created resource",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "matterId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "assigneeRelationId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "taskType": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    },
                    "startDate": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "dueDate": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "doneDate": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "escalationDate": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "recurrenceRule": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "freq": {
                          "type": "string",
                          "enum": [
                            "daily",
                            "weekly",
                            "monthly"
                          ]
                        },
                        "interval": {
                          "type": "integer",
                          "exclusiveMinimum": 0
                        },
                        "until": {
                          "type": "string",
                          "format": "date"
                        },
                        "count": {
                          "type": "integer",
                          "exclusiveMinimum": 0
                        }
                      },
                      "required": [
                        "freq",
                        "interval"
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "matterId",
                    "assigneeRelationId",
                    "taskType",
                    "status",
                    "description",
                    "startDate",
                    "dueDate",
                    "doneDate",
                    "escalationDate",
                    "recurrenceRule",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "summary": "List webhook subscriptions (scope webhooks:admin)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "eventType": {
                            "type": "string",
                            "enum": [
                              "matter.created",
                              "relation.created",
                              "hour.created",
                              "task.created",
                              "invoice.sent"
                            ]
                          },
                          "url": {
                            "type": "string"
                          },
                          "active": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "eventType",
                          "url",
                          "active",
                          "createdAt"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "skip": {
                      "type": "integer"
                    },
                    "top": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "skip",
                    "top"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Create a webhook subscription (scope webhooks:admin)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "eventType": {
                    "type": "string",
                    "enum": [
                      "matter.created",
                      "relation.created",
                      "hour.created",
                      "task.created",
                      "invoice.sent"
                    ]
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "secret": {
                    "type": "string",
                    "minLength": 16
                  },
                  "active": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "eventType",
                  "url",
                  "secret"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created resource",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "eventType": {
                      "type": "string",
                      "enum": [
                        "matter.created",
                        "relation.created",
                        "hour.created",
                        "task.created",
                        "invoice.sent"
                      ]
                    },
                    "url": {
                      "type": "string"
                    },
                    "active": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "eventType",
                    "url",
                    "active",
                    "createdAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices": {
      "get": {
        "tags": [
          "billing"
        ],
        "summary": "List invoices (scope billing:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "number": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "matterId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "debtorRelationId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "departmentId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "state": {
                            "type": "string"
                          },
                          "issueDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "dueDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "currency": {
                            "type": "string"
                          },
                          "netCents": {
                            "type": "integer"
                          },
                          "vatCents": {
                            "type": "integer"
                          },
                          "grossCents": {
                            "type": "integer"
                          },
                          "paymentStatus": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "number",
                          "matterId",
                          "debtorRelationId",
                          "departmentId",
                          "state",
                          "issueDate",
                          "dueDate",
                          "currency",
                          "netCents",
                          "vatCents",
                          "grossCents",
                          "paymentStatus",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "skip": {
                      "type": "integer"
                    },
                    "top": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "skip",
                    "top"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bi": {
      "get": {
        "tags": [
          "bi"
        ],
        "summary": "OData service document listing the BI entity sets (scope bi:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OData v4 service document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "@odata.context": {
                      "type": "string"
                    },
                    "value": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "EntitySet"
                            ]
                          },
                          "url": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "name",
                          "kind",
                          "url"
                        ]
                      }
                    }
                  },
                  "required": [
                    "@odata.context",
                    "value"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bi/$metadata": {
      "get": {
        "tags": [
          "bi"
        ],
        "summary": "OData v4 $metadata (EDMX) for the BI entity sets (scope bi:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "EDMX CSDL document",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bi/matters": {
      "get": {
        "tags": [
          "bi"
        ],
        "summary": "BI: denormalized matters (scope bi:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OData v4 collection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "@odata.context": {
                      "type": "string"
                    },
                    "value": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "matterId": {
                            "type": "string"
                          },
                          "matterNumber": {
                            "type": "string"
                          },
                          "matterName": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "flavor": {
                            "type": "string"
                          },
                          "practiceArea": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "departmentId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "openDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "closedDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "matterId",
                          "matterNumber",
                          "matterName",
                          "status",
                          "flavor",
                          "practiceArea",
                          "departmentId",
                          "openDate",
                          "closedDate"
                        ]
                      }
                    },
                    "@odata.nextLink": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "@odata.context",
                    "value"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bi/hours": {
      "get": {
        "tags": [
          "bi"
        ],
        "summary": "BI: denormalized hours (scope bi:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OData v4 collection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "@odata.context": {
                      "type": "string"
                    },
                    "value": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "hourEntryId": {
                            "type": "string"
                          },
                          "matterId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "matterNumber": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "employeeUserId": {
                            "type": "string"
                          },
                          "date": {
                            "type": "string"
                          },
                          "workedHours": {
                            "type": "number"
                          },
                          "billableHours": {
                            "type": "number"
                          },
                          "timeClass": {
                            "type": "string"
                          },
                          "rateCents": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "amountCents": {
                            "type": "integer"
                          },
                          "billed": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "hourEntryId",
                          "matterId",
                          "matterNumber",
                          "employeeUserId",
                          "date",
                          "workedHours",
                          "billableHours",
                          "timeClass",
                          "rateCents",
                          "amountCents",
                          "billed"
                        ]
                      }
                    },
                    "@odata.nextLink": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "@odata.context",
                    "value"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bi/billing": {
      "get": {
        "tags": [
          "bi"
        ],
        "summary": "BI: denormalized billing (scope bi:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "Page size ($top, max 200).",
              "example": 50
            },
            "required": false,
            "description": "Page size ($top, max 200).",
            "name": "$top",
            "in": "query"
          },
          {
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "description": "Offset ($skip).",
              "example": 0
            },
            "required": false,
            "description": "Offset ($skip).",
            "name": "$skip",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OData v4 collection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "@odata.context": {
                      "type": "string"
                    },
                    "value": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "invoiceId": {
                            "type": "string"
                          },
                          "invoiceNumber": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "matterId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "debtorRelationId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "departmentId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "state": {
                            "type": "string"
                          },
                          "issueDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "netCents": {
                            "type": "integer"
                          },
                          "vatCents": {
                            "type": "integer"
                          },
                          "grossCents": {
                            "type": "integer"
                          },
                          "paymentStatus": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "invoiceId",
                          "invoiceNumber",
                          "matterId",
                          "debtorRelationId",
                          "departmentId",
                          "state",
                          "issueDate",
                          "netCents",
                          "vatCents",
                          "grossCents",
                          "paymentStatus"
                        ]
                      }
                    },
                    "@odata.nextLink": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "@odata.context",
                    "value"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/devices": {
      "get": {
        "tags": [
          "offline-sync"
        ],
        "summary": "List devices for the calling staff API token user (scope sync:read)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Registered devices; plaintext tokens are never returned here",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "platform": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "lastSeenAt": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "revoked": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "platform",
                          "createdAt",
                          "lastSeenAt",
                          "revoked"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "items",
                    "total"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "offline-sync"
        ],
        "summary": "Register a device and return its device bearer token once (scope sync:write)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "platform": {
                    "type": "string",
                    "enum": [
                      "macos",
                      "windows",
                      "linux"
                    ]
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered device with one-time plaintext device token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "platform": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "token": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "platform",
                    "token"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/devices/{id}": {
      "delete": {
        "tags": [
          "offline-sync"
        ],
        "summary": "Revoke one of the calling user’s devices (scope sync:write)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Device revoked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "revoked": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "revoked"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/bootstrap": {
      "get": {
        "tags": [
          "offline-sync"
        ],
        "summary": "Bootstrap an offline-sync device session (device bearer token)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Device, actor, visible matters, and selected contract version",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contractVersion": {
                      "type": "string",
                      "enum": [
                        "v1"
                      ]
                    },
                    "device": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "platform": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "platform"
                      ]
                    },
                    "user": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ]
                    },
                    "matters": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "number": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "subscribed": {
                            "type": "boolean"
                          },
                          "enabled": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "number",
                          "name",
                          "status",
                          "subscribed",
                          "enabled"
                        ]
                      }
                    }
                  },
                  "required": [
                    "contractVersion",
                    "device",
                    "user",
                    "matters"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/subscriptions": {
      "post": {
        "tags": [
          "offline-sync"
        ],
        "summary": "Enable or disable a matter subscription for the authenticated device",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "matterId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "matterId",
                  "enabled"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscription state and selected contract version",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contractVersion": {
                      "type": "string",
                      "enum": [
                        "v1"
                      ]
                    },
                    "matterId": {
                      "type": "string"
                    },
                    "enabled": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "contractVersion",
                    "matterId",
                    "enabled"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/matters/{id}/reconcile": {
      "post": {
        "tags": [
          "offline-sync"
        ],
        "summary": "Compute the server-owned sync plan for a matter",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "supportedContractVersions": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "v1"
                      ]
                    },
                    "minItems": 1,
                    "default": [
                      "v1"
                    ]
                  },
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "relativePath": {
                          "type": "string",
                          "minLength": 1
                        },
                        "checksum": {
                          "type": "string",
                          "minLength": 1
                        },
                        "size": {
                          "type": "integer",
                          "minimum": 0
                        }
                      },
                      "required": [
                        "relativePath",
                        "checksum",
                        "size"
                      ]
                    },
                    "maxItems": 50000
                  }
                },
                "required": [
                  "files"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Server-computed sync plan and DMS metadata for downloads/conflicts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contractVersion": {
                      "type": "string",
                      "enum": [
                        "v1"
                      ]
                    },
                    "matterId": {
                      "type": "string"
                    },
                    "plan": {
                      "type": "object",
                      "properties": {
                        "actions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "download",
                                  "upload",
                                  "conflict",
                                  "dms_deleted",
                                  "device_deleted"
                                ]
                              },
                              "reason": {
                                "type": "string",
                                "enum": [
                                  "new",
                                  "dms_changed",
                                  "device_changed"
                                ]
                              },
                              "relativePath": {
                                "type": "string"
                              },
                              "documentId": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "detail": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "kind",
                              "relativePath"
                            ]
                          }
                        },
                        "summary": {
                          "type": "object",
                          "properties": {
                            "download": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "upload": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "conflict": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "dmsDeleted": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "deviceDeleted": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "noop": {
                              "type": "integer",
                              "minimum": 0
                            }
                          },
                          "required": [
                            "download",
                            "upload",
                            "conflict",
                            "dmsDeleted",
                            "deviceDeleted",
                            "noop"
                          ]
                        }
                      },
                      "required": [
                        "actions",
                        "summary"
                      ]
                    },
                    "documents": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "relativePath": {
                            "type": "string"
                          },
                          "checksum": {
                            "type": "string"
                          },
                          "size": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "contentType": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "contentPath": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "relativePath",
                          "checksum",
                          "size",
                          "contentType",
                          "contentPath"
                        ]
                      }
                    }
                  },
                  "required": [
                    "contractVersion",
                    "matterId",
                    "plan",
                    "documents"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/documents/{id}/content": {
      "get": {
        "tags": [
          "offline-sync"
        ],
        "summary": "Download document bytes for a sync plan download action",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Binary content stream with x-blinqx-checksum header",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/matters/{id}/documents": {
      "post": {
        "tags": [
          "offline-sync"
        ],
        "summary": "Upload bytes for a new document or document version",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "relativePath",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "documentId",
            "in": "query"
          }
        ],
        "requestBody": {
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated existing document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contractVersion": {
                      "type": "string",
                      "enum": [
                        "v1"
                      ]
                    },
                    "documentId": {
                      "type": "string"
                    },
                    "checksum": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "contractVersion",
                    "documentId",
                    "checksum"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Created new document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contractVersion": {
                      "type": "string",
                      "enum": [
                        "v1"
                      ]
                    },
                    "documentId": {
                      "type": "string"
                    },
                    "checksum": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "contractVersion",
                    "documentId",
                    "checksum"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "413": {
            "description": "File too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/matters/{id}/commit": {
      "post": {
        "tags": [
          "offline-sync"
        ],
        "summary": "Commit the post-transfer baseline for a matter",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "supportedContractVersions": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "v1"
                      ]
                    },
                    "minItems": 1,
                    "default": [
                      "v1"
                    ]
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "relativePath": {
                          "type": "string",
                          "minLength": 1
                        },
                        "documentId": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "dmsChecksum": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "deviceChecksum": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "syncState": {
                          "type": "string",
                          "enum": [
                            "synced",
                            "conflict",
                            "dms_deleted",
                            "device_deleted",
                            "pending"
                          ]
                        }
                      },
                      "required": [
                        "relativePath",
                        "documentId",
                        "dmsChecksum",
                        "deviceChecksum",
                        "syncState"
                      ]
                    },
                    "maxItems": 50000
                  },
                  "removePaths": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 50000
                  }
                },
                "required": [
                  "items"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Committed baseline count and selected contract version",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contractVersion": {
                      "type": "string",
                      "enum": [
                        "v1"
                      ]
                    },
                    "matterId": {
                      "type": "string"
                    },
                    "committed": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "contractVersion",
                    "matterId",
                    "committed"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/contract-version": {
      "get": {
        "tags": [
          "offline-sync"
        ],
        "summary": "Advertise the currently selected offline-sync contract version",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Contract-version negotiation metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contractVersion": {
                      "type": "string",
                      "enum": [
                        "v1"
                      ]
                    },
                    "supportedContractVersions": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "v1"
                        ]
                      },
                      "minItems": 1,
                      "default": [
                        "v1"
                      ]
                    },
                    "deprecation": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "migration": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "contractVersion",
                    "deprecation",
                    "migration"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden (missing scope or permission)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "rule": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "code"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {}
}
