{
  "openapi": "3.1.0",
  "info": {
    "title": "DojoCover API",
    "version": "1.0.0",
    "description": "The practice claims API behind DojoCover (https://testdojo.dev/cover). All data is made up. Sign in with POST /login and send the token as Authorization: Bearer <token>."
  },
  "servers": [
    {
      "url": "https://testdojo.dev/api/cover"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "cookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "dc_session"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "fields": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "error"
        ]
      },
      "Policy": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "POL-2001"
          },
          "holder": {
            "enum": [
              "customer",
              "adjuster"
            ]
          },
          "type": {
            "enum": [
              "Motor",
              "Home",
              "Health",
              "Travel"
            ]
          },
          "title": {
            "type": "string"
          },
          "coverage": {
            "type": "integer"
          },
          "startDate": {
            "type": "string",
            "format": "date",
            "example": "2026-11-01"
          },
          "endDate": {
            "type": "string",
            "format": "date",
            "example": "2026-11-01"
          },
          "status": {
            "enum": [
              "Active",
              "Expired",
              "Cancelled"
            ]
          }
        }
      },
      "Claim": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "CLM-1001"
          },
          "policyId": {
            "type": "string"
          },
          "filedBy": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "incidentDate": {
            "type": "string",
            "format": "date",
            "example": "2026-11-01"
          },
          "amount": {
            "type": "integer"
          },
          "description": {
            "type": "string"
          },
          "details": {
            "type": "object"
          },
          "status": {
            "enum": [
              "Submitted",
              "Info requested",
              "Manager review",
              "Approved",
              "Rejected",
              "Withdrawn"
            ]
          },
          "payout": {
            "type": [
              "integer",
              "null"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "version": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ClaimDetail": {
        "allOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "example": "CLM-1001"
              },
              "policyId": {
                "type": "string"
              },
              "filedBy": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "incidentDate": {
                "type": "string",
                "format": "date",
                "example": "2026-11-01"
              },
              "amount": {
                "type": "integer"
              },
              "description": {
                "type": "string"
              },
              "details": {
                "type": "object"
              },
              "status": {
                "enum": [
                  "Submitted",
                  "Info requested",
                  "Manager review",
                  "Approved",
                  "Rejected",
                  "Withdrawn"
                ]
              },
              "payout": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "reason": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "version": {
                "type": "integer"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          {
            "type": "object",
            "properties": {
              "policy": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "example": "POL-2001"
                  },
                  "holder": {
                    "enum": [
                      "customer",
                      "adjuster"
                    ]
                  },
                  "type": {
                    "enum": [
                      "Motor",
                      "Home",
                      "Health",
                      "Travel"
                    ]
                  },
                  "title": {
                    "type": "string"
                  },
                  "coverage": {
                    "type": "integer"
                  },
                  "startDate": {
                    "type": "string",
                    "format": "date",
                    "example": "2026-11-01"
                  },
                  "endDate": {
                    "type": "string",
                    "format": "date",
                    "example": "2026-11-01"
                  },
                  "status": {
                    "enum": [
                      "Active",
                      "Expired",
                      "Cancelled"
                    ]
                  }
                }
              },
              "events": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "at": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "action": {
                      "type": "string"
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              },
              "documents": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "position": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "size": {
                      "type": "integer"
                    }
                  }
                }
              },
              "actions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "needsManager": {
                "type": "boolean"
              }
            }
          }
        ]
      }
    }
  },
  "paths": {
    "/register": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Create a practice account",
        "description": "Who: Anyone. Made-up details only. Returns the generated account ID and one login per role. Limited to 10 per network address per hour.",
        "responses": {
          "201": {
            "description": "Created: { accountId, currency, logins: [{ username, role }] }"
          },
          "422": {
            "description": "Validation failed: fields says which",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many registrations: wait Retry-After seconds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "fullName": "Asha Verma",
                "dateOfBirth": "1995-04-21",
                "gender": "Female",
                "phone": "+91 98765 43210",
                "address": "12 Lake View Road",
                "city": "Bengaluru",
                "state": "Karnataka",
                "postalCode": "560001",
                "country": "India",
                "password": "Choose#Your1",
                "confirmPassword": "Choose#Your1",
                "acceptTerms": true,
                "currency": "INR"
              }
            }
          }
        }
      }
    },
    "/login": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Sign in",
        "description": "Who: Anyone. Returns a token for the Authorization: Bearer header, and also sets the dc_session cookie for the browser. shortSession: true makes the session last 2 minutes.",
        "responses": {
          "200": {
            "description": "{ token, expiresAt, user: { username, role, name, accountId } }"
          },
          "400": {
            "description": "User ID or password missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Wrong user ID or password, with attempts left",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "This login is disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "423": {
            "description": "Locked out after 5 wrong passwords: try again later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "username": "QA-7K2M9-customer",
                "password": "Choose#Your1",
                "shortSession": false
              }
            }
          }
        }
      }
    },
    "/logout": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Sign out",
        "description": "Who: Anyone. Clears the cookie.",
        "responses": {
          "204": {
            "description": "Signed out"
          }
        }
      }
    },
    "/me": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "summary": "The signed-in user",
        "description": "Who: Any role. Includes the account currency and the adjuster approval limit.",
        "responses": {
          "200": {
            "description": "{ user, account: { currency, adjusterLimit }, profile, session: { expiresAt } }"
          },
          "401": {
            "description": "Not signed in, or the session expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ]
      }
    },
    "/reset": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Reset the account data",
        "description": "Who: Any role. Puts every policy, claim and login back to the starting sample data. Useful before a test run.",
        "responses": {
          "200": {
            "description": "{ reset: true }"
          },
          "401": {
            "description": "Not signed in, or the session expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ]
      }
    },
    "/account/delete": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Delete the account",
        "description": "Who: Any role. Deletes the account, every role login and all data.",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "Wrong password",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "password": "Choose#Your1"
              }
            }
          }
        }
      }
    },
    "/policies": {
      "get": {
        "tags": [
          "Policies"
        ],
        "summary": "List policies",
        "description": "Who: Any role. Customers and adjusters see the policies they hold; managers and admins see all.",
        "responses": {
          "200": {
            "description": "A page of policies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "POL-2001"
                          },
                          "holder": {
                            "enum": [
                              "customer",
                              "adjuster"
                            ]
                          },
                          "type": {
                            "enum": [
                              "Motor",
                              "Home",
                              "Health",
                              "Travel"
                            ]
                          },
                          "title": {
                            "type": "string"
                          },
                          "coverage": {
                            "type": "integer"
                          },
                          "startDate": {
                            "type": "string",
                            "format": "date",
                            "example": "2026-11-01"
                          },
                          "endDate": {
                            "type": "string",
                            "format": "date",
                            "example": "2026-11-01"
                          },
                          "status": {
                            "enum": [
                              "Active",
                              "Expired",
                              "Cancelled"
                            ]
                          }
                        }
                      }
                    },
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Not signed in, or the session expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search text",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "Motor, Home, Health or Travel",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Active, Expired or Cancelled",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "One of: id, title, type, coverage, endDate",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "asc or desc",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "Page number, from 1",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "1 to 50 (default 10)",
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "post": {
        "tags": [
          "Policies"
        ],
        "summary": "Create a policy",
        "description": "Who: Admin.",
        "responses": {
          "201": {
            "description": "The new policy, numbered POL-2009 and up",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "POL-2001"
                    },
                    "holder": {
                      "enum": [
                        "customer",
                        "adjuster"
                      ]
                    },
                    "type": {
                      "enum": [
                        "Motor",
                        "Home",
                        "Health",
                        "Travel"
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "coverage": {
                      "type": "integer"
                    },
                    "startDate": {
                      "type": "string",
                      "format": "date",
                      "example": "2026-11-01"
                    },
                    "endDate": {
                      "type": "string",
                      "format": "date",
                      "example": "2026-11-01"
                    },
                    "status": {
                      "enum": [
                        "Active",
                        "Expired",
                        "Cancelled"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "holder": "customer",
                "type": "Travel",
                "title": "Asia trip",
                "coverage": 8000,
                "startDate": "2026-01-01",
                "endDate": "2027-01-01"
              }
            }
          }
        }
      }
    },
    "/policies/{id}": {
      "get": {
        "tags": [
          "Policies"
        ],
        "summary": "One policy",
        "description": "Who: Any role.",
        "responses": {
          "200": {
            "description": "The policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "POL-2001"
                    },
                    "holder": {
                      "enum": [
                        "customer",
                        "adjuster"
                      ]
                    },
                    "type": {
                      "enum": [
                        "Motor",
                        "Home",
                        "Health",
                        "Travel"
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "coverage": {
                      "type": "integer"
                    },
                    "startDate": {
                      "type": "string",
                      "format": "date",
                      "example": "2026-11-01"
                    },
                    "endDate": {
                      "type": "string",
                      "format": "date",
                      "example": "2026-11-01"
                    },
                    "status": {
                      "enum": [
                        "Active",
                        "Expired",
                        "Cancelled"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found, or not yours to see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/policies/{id}/cancel": {
      "post": {
        "tags": [
          "Policies"
        ],
        "summary": "Cancel a policy",
        "description": "Who: Admin.",
        "responses": {
          "200": {
            "description": "The cancelled policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "POL-2001"
                    },
                    "holder": {
                      "enum": [
                        "customer",
                        "adjuster"
                      ]
                    },
                    "type": {
                      "enum": [
                        "Motor",
                        "Home",
                        "Health",
                        "Travel"
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "coverage": {
                      "type": "integer"
                    },
                    "startDate": {
                      "type": "string",
                      "format": "date",
                      "example": "2026-11-01"
                    },
                    "endDate": {
                      "type": "string",
                      "format": "date",
                      "example": "2026-11-01"
                    },
                    "status": {
                      "enum": [
                        "Active",
                        "Expired",
                        "Cancelled"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Only an active policy can be cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/claims": {
      "get": {
        "tags": [
          "Claims"
        ],
        "summary": "List claims",
        "description": "Who: Customer, adjuster, manager, admin. Customers see the claims they filed; staff see every claim.",
        "responses": {
          "200": {
            "description": "A page of claims",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "CLM-1001"
                          },
                          "policyId": {
                            "type": "string"
                          },
                          "filedBy": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "incidentDate": {
                            "type": "string",
                            "format": "date",
                            "example": "2026-11-01"
                          },
                          "amount": {
                            "type": "integer"
                          },
                          "description": {
                            "type": "string"
                          },
                          "details": {
                            "type": "object"
                          },
                          "status": {
                            "enum": [
                              "Submitted",
                              "Info requested",
                              "Manager review",
                              "Approved",
                              "Rejected",
                              "Withdrawn"
                            ]
                          },
                          "payout": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "reason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "version": {
                            "type": "integer"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    },
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Not signed in, or the session expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search text",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Submitted, Info requested, Manager review, Approved, Rejected or Withdrawn",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "One of: id, amount, status, createdAt, updatedAt",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "asc or desc",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "Page number, from 1",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "1 to 50 (default 10)",
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "post": {
        "tags": [
          "Claims"
        ],
        "summary": "File a claim",
        "description": "Who: Customer, adjuster (on their own policies). The policy must be active, the date within the policy period and not in the future, and the amount within the coverage. details depends on the type: Motor needs vehicleReg and policeReport (\"yes\" adds reportNumber PR-12345); Home needs cause; Health needs hospital; Travel needs destination. Documents are 1 to 5 entries of name, type (application/pdf, image/jpeg, image/png) and size in bytes, under 5 MB.",
        "responses": {
          "201": {
            "description": "The new claim, status Submitted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "CLM-1001"
                    },
                    "policyId": {
                      "type": "string"
                    },
                    "filedBy": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "incidentDate": {
                      "type": "string",
                      "format": "date",
                      "example": "2026-11-01"
                    },
                    "amount": {
                      "type": "integer"
                    },
                    "description": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object"
                    },
                    "status": {
                      "enum": [
                        "Submitted",
                        "Info requested",
                        "Manager review",
                        "Approved",
                        "Rejected",
                        "Withdrawn"
                      ]
                    },
                    "payout": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "version": {
                      "type": "integer"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "This role cannot file claims",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed: fields says which",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "policyId": "POL-2001",
                "incidentDate": "2026-11-01",
                "amount": 1200,
                "description": "Rear bumper damaged in a car park.",
                "details": {
                  "vehicleReg": "KA01AB1234",
                  "policeReport": "no"
                },
                "documents": [
                  {
                    "name": "photo.jpg",
                    "type": "image/jpeg",
                    "size": 204800
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/claims/{id}": {
      "get": {
        "tags": [
          "Claims"
        ],
        "summary": "One claim, with history and allowed actions",
        "description": "Who: Any role who can see it. actions lists what the signed-in role may do now. version is needed to change the claim.",
        "responses": {
          "200": {
            "description": "The claim",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "CLM-1001"
                        },
                        "policyId": {
                          "type": "string"
                        },
                        "filedBy": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "incidentDate": {
                          "type": "string",
                          "format": "date",
                          "example": "2026-11-01"
                        },
                        "amount": {
                          "type": "integer"
                        },
                        "description": {
                          "type": "string"
                        },
                        "details": {
                          "type": "object"
                        },
                        "status": {
                          "enum": [
                            "Submitted",
                            "Info requested",
                            "Manager review",
                            "Approved",
                            "Rejected",
                            "Withdrawn"
                          ]
                        },
                        "payout": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "reason": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "version": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "properties": {
                        "policy": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "POL-2001"
                            },
                            "holder": {
                              "enum": [
                                "customer",
                                "adjuster"
                              ]
                            },
                            "type": {
                              "enum": [
                                "Motor",
                                "Home",
                                "Health",
                                "Travel"
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "coverage": {
                              "type": "integer"
                            },
                            "startDate": {
                              "type": "string",
                              "format": "date",
                              "example": "2026-11-01"
                            },
                            "endDate": {
                              "type": "string",
                              "format": "date",
                              "example": "2026-11-01"
                            },
                            "status": {
                              "enum": [
                                "Active",
                                "Expired",
                                "Cancelled"
                              ]
                            }
                          }
                        },
                        "events": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "at": {
                                "type": "string"
                              },
                              "role": {
                                "type": "string"
                              },
                              "action": {
                                "type": "string"
                              },
                              "note": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            }
                          }
                        },
                        "documents": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "position": {
                                "type": "integer"
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "size": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        "actions": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "needsManager": {
                          "type": "boolean"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found, or not yours to see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/claims/{id}/actions": {
      "post": {
        "tags": [
          "Claims"
        ],
        "summary": "Act on a claim",
        "description": "Who: Depends on the action. action is request-info (adjuster, needs note), approve (adjuster or manager, optional payout up to the amount), reject (adjuster or manager, needs note as the reason), respond (customer, needs note) or withdraw (customer). An adjuster approving a claim above their limit sends it to Manager review. Nobody can decide a claim they filed. version must match the claim's current version.",
        "responses": {
          "200": {
            "description": "The updated claim",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "CLM-1001"
                        },
                        "policyId": {
                          "type": "string"
                        },
                        "filedBy": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "incidentDate": {
                          "type": "string",
                          "format": "date",
                          "example": "2026-11-01"
                        },
                        "amount": {
                          "type": "integer"
                        },
                        "description": {
                          "type": "string"
                        },
                        "details": {
                          "type": "object"
                        },
                        "status": {
                          "enum": [
                            "Submitted",
                            "Info requested",
                            "Manager review",
                            "Approved",
                            "Rejected",
                            "Withdrawn"
                          ]
                        },
                        "payout": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "reason": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "version": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "properties": {
                        "policy": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "POL-2001"
                            },
                            "holder": {
                              "enum": [
                                "customer",
                                "adjuster"
                              ]
                            },
                            "type": {
                              "enum": [
                                "Motor",
                                "Home",
                                "Health",
                                "Travel"
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "coverage": {
                              "type": "integer"
                            },
                            "startDate": {
                              "type": "string",
                              "format": "date",
                              "example": "2026-11-01"
                            },
                            "endDate": {
                              "type": "string",
                              "format": "date",
                              "example": "2026-11-01"
                            },
                            "status": {
                              "enum": [
                                "Active",
                                "Expired",
                                "Cancelled"
                              ]
                            }
                          }
                        },
                        "events": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "at": {
                                "type": "string"
                              },
                              "role": {
                                "type": "string"
                              },
                              "action": {
                                "type": "string"
                              },
                              "note": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            }
                          }
                        },
                        "documents": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "position": {
                                "type": "integer"
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "size": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        "actions": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "needsManager": {
                          "type": "boolean"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "version missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "This role cannot do this, or it is their own claim",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Someone else changed the claim (version mismatch), or the action does not fit its status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "note or payout invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "action": "approve",
                "version": 1,
                "payout": 1000,
                "note": "Approved after review"
              }
            }
          }
        }
      }
    },
    "/claims/{id}/feedback": {
      "post": {
        "tags": [
          "Claims"
        ],
        "summary": "Rate a decided claim",
        "description": "Who: Customer.",
        "responses": {
          "200": {
            "description": "The claim, with a Feedback event",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "CLM-1001"
                        },
                        "policyId": {
                          "type": "string"
                        },
                        "filedBy": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "incidentDate": {
                          "type": "string",
                          "format": "date",
                          "example": "2026-11-01"
                        },
                        "amount": {
                          "type": "integer"
                        },
                        "description": {
                          "type": "string"
                        },
                        "details": {
                          "type": "object"
                        },
                        "status": {
                          "enum": [
                            "Submitted",
                            "Info requested",
                            "Manager review",
                            "Approved",
                            "Rejected",
                            "Withdrawn"
                          ]
                        },
                        "payout": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "reason": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "version": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "properties": {
                        "policy": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "POL-2001"
                            },
                            "holder": {
                              "enum": [
                                "customer",
                                "adjuster"
                              ]
                            },
                            "type": {
                              "enum": [
                                "Motor",
                                "Home",
                                "Health",
                                "Travel"
                              ]
                            },
                            "title": {
                              "type": "string"
                            },
                            "coverage": {
                              "type": "integer"
                            },
                            "startDate": {
                              "type": "string",
                              "format": "date",
                              "example": "2026-11-01"
                            },
                            "endDate": {
                              "type": "string",
                              "format": "date",
                              "example": "2026-11-01"
                            },
                            "status": {
                              "enum": [
                                "Active",
                                "Expired",
                                "Cancelled"
                              ]
                            }
                          }
                        },
                        "events": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "at": {
                                "type": "string"
                              },
                              "role": {
                                "type": "string"
                              },
                              "action": {
                                "type": "string"
                              },
                              "note": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            }
                          }
                        },
                        "documents": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "position": {
                                "type": "integer"
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "size": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        "actions": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "needsManager": {
                          "type": "boolean"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Not decided yet, or already rated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "rating must be 1 to 5",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "rating": 4,
                "comment": "Quick payout"
              }
            }
          }
        }
      }
    },
    "/admin/users": {
      "get": {
        "tags": [
          "Admin and reports"
        ],
        "summary": "List the role logins",
        "description": "Who: Admin.",
        "responses": {
          "200": {
            "description": "{ items: [{ username, role, roleName, name, status, failedAttempts }] }"
          },
          "401": {
            "description": "Not signed in, or the session expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ]
      }
    },
    "/admin/users/{role}": {
      "patch": {
        "tags": [
          "Admin and reports"
        ],
        "summary": "Disable, enable or unlock a login",
        "description": "Who: Admin.",
        "responses": {
          "200": {
            "description": "The updated user"
          },
          "409": {
            "description": "An admin cannot disable their own login",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "role",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "disabled": true,
                "clearLockout": false
              }
            }
          }
        }
      }
    },
    "/reports/claims": {
      "get": {
        "tags": [
          "Admin and reports"
        ],
        "summary": "Claims summary",
        "description": "Who: Manager, admin.",
        "responses": {
          "200": {
            "description": "{ total, byStatus, byType, amountClaimed, amountPaid }"
          },
          "422": {
            "description": "Invalid dates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Filed on or after, YYYY-MM-DD",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Filed on or before, YYYY-MM-DD",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/reports/claims.csv": {
      "get": {
        "tags": [
          "Admin and reports"
        ],
        "summary": "Claims as a CSV download",
        "description": "Who: Manager, admin.",
        "responses": {
          "200": {
            "description": "text/csv with Content-Disposition: attachment"
          },
          "401": {
            "description": "Not signed in, or the session expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          },
          {
            "cookie": []
          }
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "As above",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "As above",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  }
}
