{
 "openapi": "3.0.3",
 "info": {
  "title": "Bramble Paper API",
  "version": "2026-11-13",
  "description": "Bramble Paper: document management on top of Drive. Cabinets (Drive libraries), documents with recognised text, labels (tags, correspondents, document types), saved views, bulk changes, locked PDFs, and mail intake rules that file attachments automatically.\n"
 },
 "servers": [
  {
   "url": "https://{org}.brambleit.cloud/paper",
   "variables": {
    "org": {
     "default": "your-org"
    }
   }
  }
 ],
 "components": {
  "securitySchemes": {
   "apiKey": {
    "type": "apiKey",
    "in": "header",
    "name": "X-API-Key"
   },
   "session": {
    "type": "apiKey",
    "in": "cookie",
    "name": "sso_session"
   },
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "bearerFormat": "JWT"
   }
  }
 },
 "tags": [
  {
   "name": "Documents",
   "description": "Searching and listing documents, one document, its file and thumbnail, editing, bulk changes, reprocessing, locked PDFs, sharing links, and saved views."
  },
  {
   "name": "Cabinets",
   "description": "Cabinets (from Drive libraries), their folder templates, watching Drive for new files, and saved passwords for locked PDFs."
  },
  {
   "name": "Labels",
   "description": "Tags, correspondents and document types, with their matching rules."
  },
  {
   "name": "Mail intake",
   "description": "Mailboxes Paper checks, and the rules that file their attachments into cabinets."
  },
  {
   "name": "Share to Paper",
   "description": "Where \"Share to Paper\" from a phone lands."
  }
 ],
 "paths": {
  "/api/me": {
   "get": {
    "tags": [
     "Documents"
    ],
    "summary": "Who you are: the signed-in person and what they can do here",
    "operationId": "get-api-me",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "user": {
           "type": "object",
           "properties": {
            "id": {
             "type": "integer"
            },
            "name": {
             "type": "string"
            },
            "first_name": {
             "type": "string"
            },
            "email": {
             "type": "string"
            }
           }
          },
          "cabinets": {
           "type": "array",
           "items": {}
          },
          "tags": {
           "type": "array",
           "items": {}
          },
          "correspondents": {
           "type": "array",
           "items": {}
          },
          "doctypes": {
           "type": "array",
           "items": {}
          },
          "inbox": {},
          "locked": {},
          "views": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "integer",
              "nullable": true
             },
             "name": {
              "type": "string"
             },
             "filters": {
              "type": "array",
              "items": {}
             }
            }
           }
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/documents": {
   "get": {
    "tags": [
     "Documents"
    ],
    "summary": "Search and list documents",
    "operationId": "get-api-documents",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "sort",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "Sort order (e.g. date, added, title)."
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number"
      },
      "description": "How many."
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number"
      },
      "description": "Where to start."
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/documents/{id}": {
   "get": {
    "tags": [
     "Documents"
    ],
    "summary": "Get a document",
    "operationId": "get-api-documents-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   },
   "patch": {
    "tags": [
     "Documents"
    ],
    "summary": "Update a document",
    "operationId": "patch-api-documents-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     },
     "400": {
      "description": "Give the document a title"
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "title": {
          "type": "string",
          "description": "Its title."
         },
         "date": {
          "type": "string",
          "format": "date",
          "description": "Its date."
         },
         "correspondent_id": {
          "type": "integer",
          "description": "Who it's from."
         },
         "doctype_id": {
          "type": "integer",
          "description": "What kind of document it is."
         },
         "notes": {
          "type": "string",
          "description": "Notes (stored encrypted)."
         },
         "asn": {
          "type": "string",
          "description": "Archive serial number."
         },
         "tag_ids": {
          "type": "array",
          "items": {},
          "description": "Its tags."
         }
        }
       }
      }
     }
    }
   },
   "delete": {
    "tags": [
     "Documents"
    ],
    "summary": "Delete a document",
    "operationId": "delete-api-documents-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/documents/bulk": {
   "post": {
    "tags": [
     "Documents"
    ],
    "summary": "Change many documents at once",
    "operationId": "post-api-documents-bulk",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "all": {},
         "filters": {
          "type": "array",
          "items": {}
         },
         "ids": {
          "type": "array",
          "items": {},
          "description": "The documents (or `all` with `filters`)."
         },
         "op": {
          "type": "string",
          "description": "`add_tags`, `remove_tags`, `set_correspondent`, `set_doctype`, `checked`, `reprocess` or `delete`."
         },
         "value": {
          "description": "The tags, correspondent or type to set."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/documents/{id}/reprocess": {
   "post": {
    "tags": [
     "Documents"
    ],
    "summary": "Read a document's text again",
    "operationId": "post-api-documents-id-reprocess",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "number"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/documents/{id}/file": {
   "get": {
    "tags": [
     "Documents"
    ],
    "summary": "The file itself, streamed from Drive (Range passed on, for PDF.js)",
    "operationId": "get-api-documents-id-file",
    "description": "The file itself, streamed from Drive (Range passed on, for PDF.js). The document as a PDF: Paper's PDF copy when there is one (photos, scans, text, unlocked PDFs), otherwise the file itself. ?original=1 always gives the file as it was added. ?download=1 saves rather than opens.\n\nRequires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "original",
      "in": "query",
      "required": false,
      "schema": {}
     },
     {
      "name": "download",
      "in": "query",
      "required": false,
      "schema": {}
     }
    ],
    "responses": {
     "200": {
      "description": "Success"
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/documents/{id}/unlock": {
   "post": {
    "tags": [
     "Documents"
    ],
    "summary": "Unlock a password-protected PDF",
    "operationId": "post-api-documents-id-unlock",
    "description": "A locked PDF: try a password now. { password, remember } — remember keeps it for the cabinet, and every other locked PDF there gets another go.\n\nRequires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "retried": {}
         }
        }
       }
      }
     },
     "400": {
      "description": "Enter the password"
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "password": {
          "description": "The PDF's password."
         },
         "remember": {
          "description": "Save the password for this cabinet."
         },
         "label": {
          "type": "string",
          "description": "A name for the saved password."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/documents/{id}/thumb": {
   "get": {
    "tags": [
     "Documents"
    ],
    "summary": "A document's thumbnail",
    "operationId": "get-api-documents-id-thumb",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "File, page or redirect"
     },
     "404": {
      "description": "No preview"
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/documents/{id}/sharing": {
   "get": {
    "tags": [
     "Documents"
    ],
    "summary": "Sharing is Drive's: links (with expiry, password, download switch) and people/groups",
    "operationId": "get-api-documents-id-sharing",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/documents/{id}/links": {
   "post": {
    "tags": [
     "Documents"
    ],
    "summary": "Create a share link",
    "operationId": "post-api-documents-id-links",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "expires_days": {
          "type": "integer"
         },
         "password": {},
         "allow_download": {
          "type": "boolean"
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/documents/{id}/links/{lid}": {
   "delete": {
    "tags": [
     "Documents"
    ],
    "summary": "Delete a share link",
    "operationId": "delete-api-documents-id-links-lid",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "lid",
      "in": "path",
      "required": true,
      "schema": {
       "type": "number"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/upload": {
   "post": {
    "tags": [
     "Documents"
    ],
    "summary": "Add a document",
    "operationId": "post-api-upload",
    "description": "The request body is the file's bytes.\n\nRequires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "cabinet",
      "in": "query",
      "required": false,
      "schema": {},
      "description": "The cabinet."
     },
     {
      "name": "name",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "The file name."
     }
    ],
    "responses": {
     "400": {
      "description": "The file needs a name"
     },
     "411": {
      "description": "Content-Length is required"
     },
     "413": {
      "description": "Files can be up to 500 MB"
     },
     "duplicate ? 200 : 201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "duplicate": {}
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/cabinets": {
   "get": {
    "tags": [
     "Cabinets"
    ],
    "summary": "List cabinets",
    "operationId": "get-api-cabinets",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "cabinets": {
           "type": "array",
           "items": {}
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   },
   "post": {
    "tags": [
     "Cabinets"
    ],
    "summary": "Make a library a cabinet",
    "operationId": "post-api-cabinets",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [],
    "responses": {
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "library_id": {
          "type": "integer",
          "description": "The Drive library."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/cabinets/libraries": {
   "get": {
    "tags": [
     "Cabinets"
    ],
    "summary": "Drive libraries that could become cabinets",
    "operationId": "get-api-cabinets-libraries",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "libraries": {
           "type": "array",
           "items": {}
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/cabinets/{id}": {
   "patch": {
    "tags": [
     "Cabinets"
    ],
    "summary": "Update a cabinet",
    "operationId": "patch-api-cabinets-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "path_template": {
          "description": "How filed documents are named and foldered."
         },
         "watch_drive": {
          "description": "Pick up files added to the library in Drive."
         }
        }
       }
      }
     }
    }
   },
   "delete": {
    "tags": [
     "Cabinets"
    ],
    "summary": "Stop using a library as a cabinet",
    "operationId": "delete-api-cabinets-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/cabinets/{id}/passwords": {
   "get": {
    "tags": [
     "Cabinets"
    ],
    "summary": "Saved passwords for locked PDFs (labels only — never the passwords back)",
    "operationId": "get-api-cabinets-id-passwords",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "passwords": {
           "type": "array",
           "items": {}
          },
          "locked": {
           "type": "number"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   },
   "post": {
    "tags": [
     "Cabinets"
    ],
    "summary": "Save a password for locked PDFs",
    "operationId": "post-api-cabinets-id-passwords",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "password": {},
         "label": {
          "type": "string"
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/cabinets/{id}/passwords/{pid}": {
   "delete": {
    "tags": [
     "Cabinets"
    ],
    "summary": "Delete a saved password",
    "operationId": "delete-api-cabinets-id-passwords-pid",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "pid",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/labels/{kind}": {
   "get": {
    "tags": [
     "Labels"
    ],
    "summary": "List labels",
    "operationId": "get-api-labels-kind",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "kind",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "tags",
        "correspondents",
        "doctypes"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array",
           "items": {}
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   },
   "post": {
    "tags": [
     "Labels"
    ],
    "summary": "Create a label",
    "operationId": "post-api-labels-kind",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "kind",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "cabinet_id": {
          "type": "integer"
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/labels/{kind}/{id}": {
   "patch": {
    "tags": [
     "Labels"
    ],
    "summary": "Update a label",
    "operationId": "patch-api-labels-kind-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "kind",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "cabinet_id": {
          "type": "integer"
         }
        }
       }
      }
     }
    }
   },
   "delete": {
    "tags": [
     "Labels"
    ],
    "summary": "Delete a label",
    "operationId": "delete-api-labels-kind-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "kind",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/views": {
   "post": {
    "tags": [
     "Documents"
    ],
    "summary": "Save a view (filters)",
    "operationId": "post-api-views",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [],
    "responses": {
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "integer"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Give the view a name"
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "name": {
          "type": "string"
         },
         "filters": {
          "type": "array",
          "items": {}
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/views/{id}": {
   "delete": {
    "tags": [
     "Documents"
    ],
    "summary": "Delete a saved view",
    "operationId": "delete-api-views-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "number"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/mail": {
   "get": {
    "tags": [
     "Mail intake"
    ],
    "summary": "Mail accounts and rules",
    "operationId": "get-api-mail",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "accounts": {
           "type": "array",
           "items": {}
          },
          "rules": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "tag_ids": {
              "type": "array",
              "items": {}
             },
             "enabled": {
              "type": "boolean"
             }
            }
           }
          },
          "log": {
           "type": "array",
           "items": {}
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/mail/accounts": {
   "post": {
    "tags": [
     "Mail intake"
    ],
    "summary": "Add a mailbox to check",
    "operationId": "post-api-mail-accounts",
    "description": "Public mail servers only; private network addresses are refused.\n\nRequires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [],
    "responses": {
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     },
     "400": {
      "description": "Enter the …"
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "port": {
          "type": "number"
         },
         "secure": {},
         "allow_self_signed": {},
         "enabled": {
          "type": "boolean"
         },
         "password": {
          "type": "string"
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/mail/accounts/{id}": {
   "patch": {
    "tags": [
     "Mail intake"
    ],
    "summary": "Update a mailbox",
    "operationId": "patch-api-mail-accounts-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     },
     "400": {
      "description": "Enter the …"
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "port": {
          "type": "number"
         },
         "secure": {},
         "allow_self_signed": {},
         "enabled": {
          "type": "boolean"
         },
         "password": {
          "type": "string"
         }
        }
       }
      }
     }
    }
   },
   "delete": {
    "tags": [
     "Mail intake"
    ],
    "summary": "Remove a mailbox",
    "operationId": "delete-api-mail-accounts-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/mail/accounts/{id}/test": {
   "post": {
    "tags": [
     "Mail intake"
    ],
    "summary": "Signs in and returns the folders",
    "operationId": "post-api-mail-accounts-id-test",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "message": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/mail/accounts/{id}/check": {
   "post": {
    "tags": [
     "Mail intake"
    ],
    "summary": "Check a mailbox now",
    "operationId": "post-api-mail-accounts-id-check",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/api/mail/rules": {
   "post": {
    "tags": [
     "Mail intake"
    ],
    "summary": "Create a mail rule",
    "operationId": "post-api-mail-rules",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [],
    "responses": {
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "integer"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "account_id": {
          "type": "integer"
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/mail/rules/{id}": {
   "patch": {
    "tags": [
     "Mail intake"
    ],
    "summary": "Update a mail rule",
    "operationId": "patch-api-mail-rules-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Give the rule a name"
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "name": {
          "type": "string"
         },
         "cabinet_id": {
          "type": "integer"
         },
         "enabled": {
          "type": "boolean"
         },
         "sort": {
          "type": "number"
         },
         "max_age_days": {
          "type": "number"
         },
         "title_from": {
          "type": "string"
         },
         "correspondent_mode": {
          "type": "string",
          "enum": [
           "match",
           "sender",
           "set"
          ]
         },
         "action": {
          "type": "string",
          "enum": [
           "read",
           "flag",
           "move",
           "delete",
           "none"
          ]
         },
         "tag_ids": {
          "type": "array",
          "items": {}
         },
         "correspondent_id": {
          "type": "integer"
         },
         "doctype_id": {
          "type": "integer"
         },
         "action_folder": {}
        }
       }
      }
     }
    }
   },
   "delete": {
    "tags": [
     "Mail intake"
    ],
    "summary": "Delete a mail rule",
    "operationId": "delete-api-mail-rules-id",
    "description": "Requires: Signed-in browser session (the `sso_session` / `session_id` cookies from Bramble sign-in). Licence: Paper.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  },
  "/share": {
   "post": {
    "tags": [
     "Share to Paper"
    ],
    "summary": "\"Share to Paper\" from a phone lands here only if the service worker (which normally takes the files) isn't installed yet: just open the app",
    "operationId": "post-share",
    "description": "Requires: None: public, or protected by a token in the address or body.",
    "parameters": [],
    "responses": {
     "200": {
      "description": "File, page or redirect"
     }
    },
    "security": [
     {
      "session": []
     }
    ]
   }
  }
 }
}