Skip to content

Reference

Everything the app knows of, to look up: the settings, the keys in which Nextcloud keeps them, the routes, the versions that the tests cover, where data goes, and what stays when the app goes.

Settings

The settings are under Administration settings → Paperless Unified Search, for administrators only, and hold for every user of the Nextcloud. Test connection and save stores the connection only once Paperless answers, and while one is stored, a failed test still stores the archive account and the three switches; it and Disconnect ask for the password when it wasn't confirmed in the last 30 minutes.

Setting What it does Default App config key
Paperless URL The address of Paperless, with a path when Paperless runs under one, such as https://paperless.example.com — paperless_url
Paperless runs in my local network Lets Nextcloud reach this URL, and no other, at an address of the local network, without redirects (details) Off allow_local
Paperless API token The token of the Paperless account of the search; blank keeps the stored one, for the same server — None: in Nextcloud's credentials manager, as paperless_unified_search.api-token
Archive account The Nextcloud account whose files stand for the documents; blank takes the account of Paperless Sync The account of Paperless Sync archive_owner
Always include Paperless in global search Asks Paperless in every search of every user, without Search connected services; reload Nextcloud after a change Off always_search
Let users include Paperless in all their searches Lets each user choose Always search my Paperless documents in their personal settings; off hides the choice, and the search ignores what users chose On personal_always_search
Let users ask for notifications about new documents Lets each user save searches for notifications in their personal settings; off hides the choice, and the job asks Paperless nothing On where Nextcloud has a memory cache, until an administrator chooses new_document_alerts

Disconnect deletes the URL, the token, the switches, the archive account, the version of Paperless, the progress of the notifications about new documents and the history of the problems. Clear history deletes only the history.

Personal settings

Under Personal settings → Paperless, each user can select Always search my Paperless documents: every search of their own then asks Paperless without Search connected services, from the next page that they open, and the terms go to the Paperless server even when they look for a file or a contact. The checkbox saves as it changes. The section shows while Paperless is connected with an archive account and the administrators let users choose; while Always include Paperless in global search is on, it shows the checkbox ticked and greyed out, as every search includes Paperless anyway.

Setting Default User preference
Always search my Paperless documents Off always_search of the app, stored only while it is chosen
Notify me about new documents Off new_document_alerts of the app, a lazy value, stored only while it asks for something, as JSON: everyDocument, and the saved searches in terms

An administrator reads the choice of a user with occ user:setting <user> paperless_unified_search always_search and takes it back with occ user:setting <user> paperless_unified_search always_search --delete. While Let users include Paperless in all their searches is off, the stored choices stay but count for nothing; they count again once it is on.

App configuration

Nextcloud keeps the settings in its app configuration, which occ reads:

occ config:list paperless_unified_search
occ config:app:get paperless_unified_search paperless_url
Key Holds
paperless_url The URL of Paperless, as the settings stored it: without a slash at its end, with the host in its ASCII form
allow_local Whether Paperless runs in the local network
archive_owner The ID of the archive account, as Nextcloud spells it; missing when the settings take the account of Paperless Sync
trusted_mounts The Team folders and external storages whose files stand for documents besides those of the archive account, separated by spaces, such as team:3 external:7; missing when there are none. occ paperless_unified_search:trusted-mounts changes it
always_search Whether every search asks Paperless
personal_always_search Whether users may choose to include Paperless in every search of their own; missing means yes
new_document_alerts Whether users may ask for notifications about new documents; missing means yes where Nextcloud has a memory cache
new_document_alerts_progress How far the job of the notifications has come, as JSON: the hash of the URL of the server, the highest ID seen, the moment of the last answer, the documents that wait for their files with their titles, and the failures in a row with the end of the rest; a lazy key. The job deletes it while nobody asks for notifications
paperless_version, paperless_api_version The versions of Paperless and of its API, such as 3.3.0 and 10, as its last answer named them
token_warnings The warnings about the account of the API token that the last test of the connection found, separated by commas: superuser, staff, changes_documents, hides_correspondents, hides_document_types, hides_tags and hides_names_of_others; missing when there are none, or Paperless didn't say. A lazy key
diagnostics The history of the problems of the search, as JSON; a lazy key, which Nextcloud loads only when it is read
diagnostics_pending Whether a failure in the history still waits for a search that works

The account of Paperless Sync is occ config:app:get paperless_sync target_user. Whether it gives each user their own archive is occ config:app:get paperless_sync ownership: with per-user and per-user-shared, the files of the user of the owner of each document count too, by its user_map and user_group, and with per-user-shared the settings say that the copies for the users who may only view a document don't. Which users may see only the documents with some tags is the lazy key occ config:app:get paperless_sync user_tags, Paperless Sync's setting Tags that a user may see: a line for each such user, such as katja = Katja, Household, which Tags that a user may see explains.

Keys that an older version left and this one no longer reads go with the next update: Nextcloud runs the repair step Remove the last failed search that Paperless Unified Search 0.3.0 kept after every update of the app and on occ maintenance:repair, and it deletes last_failure and last_recovery, which the history of the problems replaced in 0.4.0.

Change the settings in the administration settings, which test the connection first. occ config:app:set can still turn a switch on or off, such as occ config:app:set paperless_unified_search always_search --value=true --type=boolean, which every user's next reload takes. Don't change paperless_url that way: the stored token would follow the URL to the new server, which the settings prevent by asking for the token again.

Set up and check it with occ

Five commands of occ do without a browser what the settings do, and more: they set the app up for Ansible, Docker and other scripts, test it for monitoring, and say why a user doesn't find a document.

Command What it does Exit code
paperless_unified_search:setup Tests the connection with the URL and the token, then saves the settings, as Test connection and save does 0 once saved, 1 when Paperless doesn't answer or a setting is wrong (while a connection is stored, a failed test still saves --archive-account and the switches other than --allow-local), 2 for a wrong call, such as a missing --url or an empty token source
paperless_unified_search:test Tests the connection with the stored settings, names the version of Paperless and warns about a token that may do more than the search needs or less than the results show 0 when Paperless answers, 1 otherwise
paperless_unified_search:search <user> <term> Searches as the user and says for each document whether it shows to them, with --explain why not 0 once Paperless answered
paperless_unified_search:check Tests the connection, what the account of the API token may do and the archive account, counts the documents of Paperless that have a file, and lists how the archive is shared 0 when the search can show documents, 1 otherwise
paperless_unified_search:trusted-mounts [<mount>...] Lists or sets the Team folders and external storages whose files stand for documents besides those of the archive account, such as team:3 external:7 0, or 2 for a name that is neither team:<ID> nor external:<ID>

Set up the app

The token never goes on the command line, where the history of the shell and the list of processes would show it to others: setup reads it from the standard input with --token-stdin, or from an environment variable with --token-env=NAME. An option that you leave out keeps its stored value, and without a token the stored one stays, but only for the server it was saved for, as on the settings page.

Option Sets
--url=URL The address of Paperless, such as https://paperless.example.com; required
--token-stdin, --token-env=NAME The API token, from the first line of the standard input or from the environment variable NAME
--archive-account=ID The account that owns the synchronized files; empty for the account of Paperless Sync
--allow-local, --no-allow-local Paperless runs in my local network
--always-search, --no-always-search Always include Paperless in global search
--personal-always-search, --no-personal-always-search Let users include Paperless in all their searches
--new-document-alerts, --no-new-document-alerts Let users ask for notifications about new documents
--create-account Creates the search account nextcloud-search in Paperless with the API token of a superuser from --token-stdin or --token-env, which is not stored, and saves the settings with the token of the account, as Create the search account and save does
--view-new-documents, --no-view-new-documents With --create-account: Let it view each new document, on unless you turn it off
--view-existing, --no-view-existing With --create-account: Let it view what Paperless has, on unless you turn it off

On a server, as the user of the web server:

printf '%s\n' "$PAPERLESS_TOKEN" | sudo -u www-data php occ paperless_unified_search:setup \
  --url=https://paperless.example.com --archive-account=paperless --token-stdin

With the token of a superuser of Paperless, which creates the search account and goes nowhere else:

printf '%s\n' "$PAPERLESS_SUPERUSER_TOKEN" | sudo -u www-data php occ paperless_unified_search:setup \
  --url=https://paperless.example.com --archive-account=paperless --create-account --token-stdin

With Docker Compose and the image of Nextcloud, from a file that only you can read:

docker compose exec -T --user www-data nextcloud php occ paperless_unified_search:setup \
  --url=http://paperless:8000 --archive-account=paperless --allow-local --token-stdin \
  < paperless-token.txt

With Ansible, from its vault, and without the token in its output:

- name: Connect Paperless Unified Search to Paperless-ngx
  ansible.builtin.command:
    argv: [php, occ, paperless_unified_search:setup, --url=https://paperless.example.com,
           --archive-account=paperless, --token-stdin]
    chdir: /var/www/nextcloud
    stdin: "{{ vault_paperless_token }}"
  become: true
  become_user: www-data
  no_log: true

Explain a hidden document

The search leaves out every document that has no file of the archive account that the searching user can open, without a trace: twelve documents that jamie may not open look exactly like none. search lists the documents that Paperless ranks first, 10 by default and up to 50 with --limit, with whether each shows to the user, and --explain names the reason of each one that doesn't:

$ occ paperless_unified_search:search jamie invoice --limit=6 --explain
+-----+-----------------------------------+------------+--------------------------------------------------------------------------------+
| ID  | Title                             | Verdict    | File                                                                           |
+-----+-----------------------------------+------------+--------------------------------------------------------------------------------+
| 412 | Electricity invoice - August 2026 | shown      | /Paperless/2026/Electricity invoice - August 2026 [P412].pdf                   |
| 389 | Home insurance renewal            | not shared | /Private/Home insurance renewal [P389].pdf of paperless, not shared with jamie |
| 371 | Internet invoice - July 2026      | shown      | /Paperless/2026/Internet invoice - July 2026 [P371].pdf                        |
| 356 | Water bill 2026                   | no file    |                                                                                |
| 344 | Old invoice                       | not owned  | /Scans/Old invoice [P344].pdf of jamie                                         |
| 330 | Parking receipt                   | writable   | /Inbox/Parking receipt [P330].pdf of paperless, jamie may write it             |
+-----+-----------------------------------+------------+--------------------------------------------------------------------------------+
Paperless found 12 document(s) for "invoice"; 2 of the 6 above show to jamie.
Writable (330): jamie may change the file of the archive account paperless, or add files to its folder, so anyone with that share could have given it the marker of the document. Share it read-only with jamie.
Not shared (389): the archive account paperless has the file, but hasn't shared it with jamie. Share the file, or a folder that holds it, read-only with jamie.
Not owned (344): jamie sees a file with the marker of the document, but only the files of the archive account paperless stand for documents.
No file (356): no file of the archive account paperless has the marker of the document, such as [P356], in its name. The synchronization hasn't written it yet, or names files without it.

Before these four questions, the search asks one more for a user whom Paperless Sync lets see only the documents with some tags (see Tags that a user may see): a document without one of them is not tagged, whatever files the user can open.

Why a document does not show: Paperless finds document 389 when jamie searches, and occ paperless_unified_search:search jamie invoice --explain asks four questions in turn. Does jamie see a file of the archive account with [P389] in its name? Then the document shows, unless jamie may change that file or add files to its folder: then it is writable, since jamie could have named it so, and sharing it read-only with jamie shows it. Otherwise, does the archive account have such a file in its own folders? Then it is not shared with jamie, and sharing the file or its folder read-only with jamie shows it. Otherwise, does jamie see a file with the marker of another account? Then it is not owned, since only files of the archive account stand for documents. Otherwise there is no file, and the synchronization has yet to write one with the marker in its name.Why a document does not show: Paperless finds document 389 when jamie searches, and occ paperless_unified_search:search jamie invoice --explain asks four questions in turn. Does jamie see a file of the archive account with [P389] in its name? Then the document shows, unless jamie may change that file or add files to its folder: then it is writable, since jamie could have named it so, and sharing it read-only with jamie shows it. Otherwise, does the archive account have such a file in its own folders? Then it is not shared with jamie, and sharing the file or its folder read-only with jamie shows it. Otherwise, does jamie see a file with the marker of another account? Then it is not owned, since only files of the archive account stand for documents. Otherwise there is no file, and the synchronization has yet to write one with the marker in its name.

Without --explain, search decides as the search itself does, with one search of the file cache, and calls every document that doesn't show hidden; with it, a search of the file cache follows for each further question, for the documents that are still unexplained. --json writes the documents for scripts, each with its id, title, verdict, path and owner. In a Team folder or an external storage that you trust, as below, a file that the user may write shows as writable mount in the table and as writable_mount in --json: let the user only read the folder there.

Check the whole set-up

check tests the connection, what the account of the API token may do and the archive account, with a warning when Paperless Sync also gives each user copies of the documents that they may view, which the search doesn't show, and compares the documents that the account of the API token sees in Paperless with the files whose names carry their markers: those of the archive account and, when Paperless Sync gives each user the documents that they own, those of the user of each owner, in that user's folders, as the search counts them:

$ occ paperless_unified_search:check
✓ Paperless 3.3.0 (API 10) answers at https://paperless.example.com.
✓ The account of the API token may change no document, and may view correspondents, document types and tags.
✓ The archive account is paperless, the account of Paperless Sync.
! Coverage: 1,180 of 1,234 Paperless document(s) have a file of the archive account. Without one, among others: 17, 18, 19, 20, 23, 31, 40, 41, 42, 57.
! Shared: 2 users, 2 groups.
! /Paperless/Inbox is shared with the user sam with write permission, so the search shows sam none of the documents in it. Share it read-only.

Documents without a file are no failure, as long as the search can show others: the synchronization may not have written them yet, or leaves some out on purpose. When not one document has a file, as with an archive account that owns none of the synchronized files, check exits with 1 and says what to correct. search --explain with a term of such a document says why it doesn't show. An account of the token that may change documents, or may not view correspondents, document types or tags, gets a line with ! and what to change, and so does one of which Paperless doesn't say what it may do, without the permission to view its UI settings; a question for it that gets no answer in time only says to run the check again. None of them fails the check.

Last, check lists with whom the archive account shares its files: the users, groups and teams, each once, other recipients such as conversations of Talk, and the public links. Each share that allows changes gets a warning with its path and its recipient, since whoever may write into the archive could give a file the marker of any document, and the search shows them none of the documents in it. check exits with 0 all the same, as the search still shows documents to the others.

Trust a Team folder or an external storage

A Team folder, or an external storage mounted for several users or groups, has no account of its own that owns its files: Nextcloud names each user who sees a file there as its owner, so the archive account can't name such a mount. trusted-mounts trusts it besides the archive account, a Team folder by its ID, as occ groupfolders:list shows it, and an external storage by its mount ID, as occ files_external:list shows it. The names replace the stored ones:

$ occ paperless_unified_search:trusted-mounts team:3 external:7
Trusted mounts: team:3, external:7. Their files stand for documents for each user who may only read them there.

A file with the marker of a document in such a mount then stands for that document for each user who may only read it there, and the settings name the trusted mounts below the shares. A user who may change a file there, or add files to its folder, sees none of its documents, since that user could have given a file any marker. So trust only a mount that nobody but the synchronization writes, also outside Nextcloud, such as the media folder of Paperless, mounted read-only for a group. An external storage that a user adds in their personal settings never counts, and neither does a file that a user shares out of the mount. --none trusts none again. check can't count the files of a trusted mount, which belong to no account, and says so; it doesn't fail without a file of the archive account then.

In the administration overview

Administration settings → Overview checks the app among the other setup checks of Nextcloud, and so does occ setupchecks. It warns when the search shows no Paperless documents for a reason that an administrator corrects, and links to the settings of the app: a token that Nextcloud can no longer decrypt, no archive account or one that doesn't exist, or a search that failed with none working since. After these, it warns when the archive account shares files with write permission, when Paperless Sync also gives each user copies of the documents that they may view, which the search doesn't show, with a link to what you can do, and when the last test of the connection found that the account of the token may change documents, or may not view correspondents, document types or tags. Otherwise it names the Paperless that the app is connected to, with the version of its last answer, and how the archive is shared. It reads only what the app stored and the shares in the database of Nextcloud, and sends no request to Paperless, so the overview opens as fast as without it.

The routes of the settings

The settings page saves through five routes of the app, which only administrators may call, each with Nextcloud's CSRF token, and the personal settings through two more that every user who signed in may call. A script calls the five with the login of an administrator, and these two with the login of the user whose choice they store, each with the header OCS-APIRequest: true, as the end-to-end tests do; /index.php goes before /apps where Nextcloud runs without pretty URLs.

Route Does
POST /apps/paperless_unified_search/settings Tests the connection and saves, with the parameters url, token, archiveOwner, allowLocal, alwaysSearch, personalAlwaysSearch and newDocumentAlerts; asks for the password like Test connection and save. When the test fails while a connection is stored, it answers the settings as stored, with connectionFailure: the message and the code of the failure
POST /apps/paperless_unified_search/settings/account Create the search account and save: creates the search account nextcloud-search in Paperless with the parameter superuserToken, the API token of a superuser, which it neither stores nor logs, and with viewNew and viewExisting, both on unless false; then tests the connection with the token of the account and saves with it, with the other parameters of the route above; asks for the password, and the log and the audit log record which administrator created the account. It answers the settings with searchAccount: its username, whether a workflow lets it view new documents, and how many documents and names it may view since the set-up
DELETE /apps/paperless_unified_search/settings Disconnect: deletes the settings, the token and the history; asks for the password
DELETE /apps/paperless_unified_search/settings/diagnostics Clear history
POST /apps/paperless_unified_search/settings/try Try a search: searches with the parameter term as the account user and says for each document whether it shows and why not, with its ID, title and tags alone; the log records which administrator tried a search as whom, without the term
POST /apps/paperless_unified_search/personal Always search my Paperless documents of the user who signed in, with the parameter alwaysSearch; answers {"alwaysSearch": true} or false, and HTTP 403 with the code not_allowed while the administrators don't let users choose
POST /apps/paperless_unified_search/personal/alerts Notify me about new documents of the user who signed in, with the parameters everyDocument and terms, a list; answers the choice as the server keeps it, without blank lines and repeats, or a message with the code not_allowed, too_many_searches for more than 10, or search_too_long for more than 500 characters
curl -u admin -H 'OCS-APIRequest: true' -H 'Accept: application/json' \
  --data-urlencode 'url=https://paperless.example.com' \
  --data-urlencode 'archiveOwner=paperless' \
  --data-urlencode "token@$HOME/.paperless-token" \
  'https://cloud.example.com/apps/paperless_unified_search/settings'

token@file hands the token over in a file, which keeps it out of the history of the shell and the list of processes. A saved setting answers HTTP 200 with the settings as JSON: url, tokenConfigured, alwaysSearch, archiveOwner, syncAccount, tokenUnreadable, archiveOwnerMissing, allowLocal, paperlessVersion, paperlessApiVersion, personalAlwaysSearch and tokenWarnings, the warnings about the account of the token as the key token_warnings names them, empty when there are none or Paperless didn't say, never the token. A save without alwaysSearch or allowLocal sets the switch to its default, off; a save without personalAlwaysSearch keeps it as it is. A refusal answers HTTP 400, or 500 when something after the test failed, with the message to show in the language of the administrator and a code:

Code Means
invalid_url, unsupported_scheme, url_extras, host_not_ascii The URL isn't one, isn't HTTP or HTTPS, has credentials, a query or a fragment, or a host that isn't in its ASCII form
token_required, token_for_other_server No token is stored, or the stored one is for another server
unknown_archive_account The archive account doesn't exist
superuser_token_required, not_superuser Creating the search account: no token of a superuser was entered, or the token belongs to no superuser of Paperless
search_account_exists Creating the search account: Paperless has the user nextcloud-search already, which stays as it is
search_workflow_exists Creating the search account with Let it view each new document: Paperless has the workflow Nextcloud search: view new documents already, which stays as it is; delete it, or turn the choice off
search_account_left Creating the search account failed halfway, and Paperless refused to remove the user, the workflow or both again: delete what the message names in Paperless
unauthorized Paperless refused the token, with HTTP 401 or 403
not_found HTTP 404: the path of the URL is wrong
redirect The URL forwards, and with the local network Nextcloud follows no redirect
http Another status, such as an error of Paperless with 5xx, or HTTP 400 of a proxy
disallowed_host HTTP 400: Paperless refused the host name of the URL, as Paperless-ngx 3.5 does for any other than the host of PAPERLESS_URL and localhost once PAPERLESS_URL is set; adding the host name to PAPERLESS_ALLOWED_HOSTS of Paperless fixes it
unsupported_version HTTP 406: Paperless is older than 2.16 and doesn't speak version 9 of its API; updating Paperless-ngx fixes it
newer_api HTTP 406 to version 10 of the API, the newest that the app knows, which it asks for once Paperless named it: Paperless is newer than the app, and updating Paperless Unified Search fixes it. A Paperless that was downgraded or restored from an older backup answers the same way until Test connection and save asks it again
not_paperless The answer isn't a list of documents of Paperless-ngx
local_address Nextcloud refused the address of the local network
tls, tls_handshake Nextcloud doesn't trust the certificate, or couldn't set up an encrypted connection
unknown_host, timeout, unreachable The host doesn't resolve, Paperless didn't answer in time, or the connection failed
internal Something after the test failed, such as the database; the log of Nextcloud has it

Troubleshooting says what to do about each.

The search and the smart picker

ID Where
The search provider paperless_unified_search_documents Paperless documents in Nextcloud's search, and GET /ocs/v2.php/search/providers/paperless_unified_search_documents/search?term=… in its OCS API, with limit (5 by default, up to 50) and cursor
The provider of the smart picker paperless_unified_search-documents Paperless documents in the smart picker of Talk, Text, Deck and Mail

Use it from scripts and AI assistants shows the answer of the API.

The dashboard widget

ID paperless_unified_search-recent, New in Paperless, offered once the settings name a Paperless and an archive account that exists
Items GET /ocs/v2.php/apps/dashboard/api/v2/widget-items?widgets[]=paperless_unified_search-recent with limit (7 by default, up to 30), as Nextcloud's dashboard and its apps ask for them: the newest documents that the user can open, each with its title, a line with the day that Paperless added it, its correspondent, its type and up to two of its tags, the link and the preview of its file, and as sinceId the moment that Paperless added it; sinceIds[paperless_unified_search-recent] with such a moment lists only the documents added after it
The link below the list Files shared with you, the view of Files with the files that others share with the user; Nextcloud's web dashboard shows it, and six documents, only once the list is full; none for the archive account
Paperless One request for the 25 documents that it added last, at most once a minute for all users together, which Nextcloud's distributed cache keeps meanwhile (with a memory cache, as Nextcloud recommends; without one, every dashboard asks Paperless); a Paperless that doesn't answer rests for a minute as well, and the widget says Paperless can't be reached right now. For a user who can open fewer of them than the widget shows, one request for each next page of 25, up to the 100 newest, and, with per-user or per-user-shared, one for the 25 newest documents that the user's own user of Paperless owns, each kept for a minute as well; once 5 seconds went, the widget asks for none of these and shows what it found. A user's documents that are older than all of these show in the search, not in the widget.

The notifications about new documents

The job OCA\PaperlessUnifiedSearch\BackgroundJob\NotifyNewDocuments, every five minutes as Nextcloud's cron allows, one run at a time; occ background-job:list --class='OCA\PaperlessUnifiedSearch\BackgroundJob\NotifyNewDocuments' shows it
It runs While Let users ask for notifications about new documents is on, Paperless is connected, an archive account exists and someone asks for notifications; otherwise it forgets its progress and asks nothing
Paperless One request per run for the new documents, and only for a document with a file in the archive account one request per distinct saved search, as below
Limits 10 saved searches per user, of up to 500 characters; 100 new documents per run; 200 documents waiting for their files, for up to two days
Rest after a failure 10, 20 and 40 minutes, then an hour until Paperless answers again
The settings Its progress, a lazy value of the configuration of the apps, changes only with news: every write of that configuration empties its cache for all of Nextcloud, so a run that finds nothing new writes nothing, the moment of the last answer alone moves at most once an hour, and a pause deletes a progress only where one is stored
The notification One per user and run; the subject new_documents, the object paperless_documents with the ID of the newest document, and the parameters count and documents with the title, the ID and the path of the file of up to three

Requests to Paperless

Every request of the app to Paperless is one GET of <URL>/api/documents/, of /api/correspondents/, /api/document_types/ and /api/tags/ for the names of the correspondents, types and tags of a page, of /api/tags/ also for the IDs of the tags that some users may see, and, in a test of the connection, of its newest documents, of /api/ui_settings/ for what the account of the token may do, or of /api/users/ for the usernames of the owners when Paperless Sync gives each user the documents that they own, from the Nextcloud server:

Headers Authorization: Token …, Accept: application/json and User-Agent: Nextcloud-Paperless-Unified-Search/<version>
The account of the token View for documents, correspondents, document types, tags and UI settings, and for users when Paperless Sync gives each user the documents that they own, and nothing else. Every answer holds only the documents, correspondents, types and tags that the account may view: those that it owns, those without an owner, and those whose permissions let it or one of its groups view them; a note of a document matches without the permission to view notes. What each permission gives the search says what each of them does
A search query with the term, page, page_size=25 and fields=id,title,created,correspondent,document_type,tags,owner,__search_hit__, and for a user who may see only the documents with some tags tags__id__in with the IDs of those tags, or no request at all while Paperless has none of them; on Paperless 3, a query that it can't parse yet once more with text in place of query
A search for similar documents For a term such as like:412, first id__in=412, page=1, page_size=1 and fields=id,owner,tags, by which the search decides whether the user may see that document, and only then more_like_id=412 in place of query, with the fields, the pages and the filters of a search; no request for an ID larger than 2147483647, which no document can have
The test of the connection page_size=1 and fields=id; once Paperless answers, /api/ui_settings/ without parameters, with 3 seconds for the answer and no second try, for the warnings about the account of the token. Of its answer, the app reads only user.is_superuser, user.is_staff and permissions; Paperless answers HTTP 403 to an account that may not view its UI settings, and the warnings stay unknown: occ and the overview then forget those of an earlier test, which a request without answer, another status or an answer that isn't JSON keep. Of an account that isn't a superuser and may view documents, it then asks for the 25 newest with ordering=-added, page=1 and fields=id,correspondent,document_type,tags, and for the names of their correspondents, types and tags, again with 3 seconds and no second try, for the warning about those that another user owns
The newest documents of the dashboard ordering=-added, page=1, page_size=25 and fields=id,title,added,correspondent,document_type,tags,owner, and page=2 to 4 while a user can open too few, then owner__id__in with the ID of the user's own user of Paperless; for a user who may see only the documents with some tags, tags__id__in with the IDs of those tags and no owner__id__in, a page that the cache keeps apart for each set of tags, and no request at all while Paperless has none of them; at most once a minute for all users, with 5 seconds for the answer and no second try
The users of Paperless Only with Paperless Sync's ownership per-user or per-user-shared: /api/users/ with page from 1 to at most 10 and page_size=1000, by the number of each page, never by the link of the next one; 3 seconds for the answer and no second try. The app keeps only the ID and username of each user, for ten minutes for all users, by the server and the token; after HTTP 403 or another answer that isn't a list it asks again after ten minutes, after a request without answer after a minute, and at once after a save of the settings and in occ paperless_unified_search:check
The owners of the documents Only occ paperless_unified_search:check, with Paperless Sync's ownership per-user or per-user-shared: ordering=id, page from 1 to at most 100, page_size=1000 and fields=id,owner, by the number of each page, never by the link of the next one; 10 seconds for each answer and no second try
The tags of Paperless Only while Paperless Sync lets a user see only the documents with some tags: /api/tags/ with page from 1 to at most 10 and page_size=1000, by the number of each page, never by the link of the next one; 3 seconds for the answer and no second try. The app keeps the ID and name of each tag, for ten minutes for all users, by the server and the token, and turns the names of a user's tags into their IDs, whatever the case; after HTTP 401 or 403 it asks again after ten minutes, after any other failure after a minute, and at once after a save of the settings and in occ paperless_unified_search:check. Meanwhile, a user with tags finds no document
The new documents of the notifications ordering=-id, page=1, page_size=100, fields=id,title,owner and added__date__gte with the day before the last answer, which keeps the answer short, in one try, every five minutes while someone asks for notifications and Paperless answers; the first run asks for page_size=1 without the day
A saved search of the notifications query with the term, on Paperless 3 for a query that it can't parse once more text with its words, id__in with the new documents that have files, page=1, page_size as many as those and fields=id, in one try, once per distinct search and only when such documents exist. While Paperless Sync lets a user see only the documents with some tags, the job first asks for the documents that wait for their files, with id__in, page=1, page_size as many as those and fields=id,owner,tags, in one try, since a tag may have come or gone since, and tells such a user only about those with one of their tags
The check of a saved search query with the term, or more_like_id for a term such as like:412, page=1, page_size=1 and fields=id, in one try, never in the simple mode, once per search that is new among those in use when a user saves them; after a request without an answer, none for the further ones
Time 3 seconds to connect, 10 seconds for the answer
A second try Only for a request that failed within 3.5 seconds, before it had a connection, and whose address Nextcloud didn't refuse
Redirects Without Paperless runs in my local network, up to 5, never to an address of the local network; Nextcloud leaves the token out of a redirect to another scheme, host or port, which Paperless then refuses, and keeps it for one within the same server. With the switch, none

Compatibility

Nextcloud 33 Nextcloud 34 Nextcloud 35
Paperless-ngx 3.x (API 10) End-to-end tests End-to-end tests End-to-end tests
Paperless-ngx 2.16 to 2.20 (API 9) Unit tests Unit tests Unit tests
  • Nextcloud: the end-to-end tests run the app in each version that appinfo/info.xml supports: in its pinned release in every pull request that changes the app and on every change of main, where Renovate moves the pins within about a week of a new release, and in its current release every Monday, so that a new release of a supported version that breaks the app opens an issue within a week, and every Monday also in the coming version of Nextcloud, its beta or release candidate.
  • Paperless-ngx: the end-to-end tests ask a stand-in of Paperless that answers as Paperless-ngx 3.3.0 does: its pages, its fields, its headers of the version, its excerpts and its refusal of a query that is still being typed. The unit tests check the answers of 2.20 and 3.3, such as that only Paperless 3 gets the simple mode of its search, which Paperless 2 doesn't know. Every request names a version of the API, so a new release of Paperless can't change the results unnoticed: version 10 where the last answer of Paperless named it, as every 3.x does, and version 9 otherwise, which Paperless-ngx 2.16 and newer speak. Version 10 leaves out the IDs of every document that matches, which Paperless computes in version 9 for each page of a search; occ paperless_unified_search:check then reads them from the pages of the documents. When Paperless refuses one version with HTTP 406, the test of the connection asks once for the other, so a Paperless that was updated or replaced since its last answer is asked in the version that it speaks. Contract tests check the app against real Paperless-ngx, the last release of 2.20 and the newest of 3.x: the fields, dates, excerpts, pages and errors of a search, the newest documents of the dashboard, and the names of the correspondents, document types and tags that a result shows, as the app asks for them. They run every week and, as the required checks paperless (2) and paperless (3), in every pull request that changes the app, so no change that breaks them reaches main. An older Paperless answers HTTP 406, and the test of the connection says so; a Paperless that no longer speaks version 10 answers it too, and the message says that the app needs an update. Before Paperless-ngx 2.20.13, Paperless doesn't check the document of a search for similar documents, the term like:: it answers an ID that it doesn't have with the error of a failed search, which the app counts as finding nothing, for that term alone, also when its index fails, and it finds similar documents for one that its account may not view, of those that the account may view.
  • PHP: 8.2 or newer, as Nextcloud supports it; the unit tests run on 8.3, as PHPUnit 12 needs it.

Data flows

From To What When
The browser or an app of the user Nextcloud The search term Whenever the user searches
Nextcloud Paperless The term, the page and the fields to answer with, and the API token With Search connected services on, after choosing Paperless documents in the smart picker, through the API, or always when Paperless is trusted
Paperless Nextcloud Of each document that the account of the token may view: its ID, title, date, the IDs of its correspondent, its type and its tags, and the excerpt around the term; the versions of Paperless and of its API In every answer
Nextcloud Paperless The request for what the account of the token may do, and for the IDs and names of the correspondents, types and tags of its newest documents, with the API token With every test of the connection: Test connection and save, occ paperless_unified_search:setup, test and check
Paperless Nextcloud The user of the token with its ID and name, whether it is a superuser or staff, its groups, its permissions and those of its groups, and the settings of the web interface of Paperless for it; the app keeps only the warnings that follow from whether it is a superuser or staff and from its permissions In every answer to an account that may view its UI settings
Nextcloud The browser or an app of the user Of each document whose file the user can open: its title, date, the names of its correspondent, its type and up to two of its tags, and its excerpt, and the link, the ID and the path of its file In every answer
Nextcloud Paperless The request for the 25 documents that Paperless added last, and for the next ones or those of an owner, with the fields that the dashboard shows, and the API token At most once a minute, when the dashboard of a user shows the widget
Paperless Nextcloud Of each of these documents that the account of the token may view: its ID, title, the moment that Paperless added it and the IDs of its correspondent, its type and its tags In every answer
Nextcloud The browser or an app of the user Of each of the newest documents whose file the user can open: its title, the day that Paperless added it, its correspondent, its type and up to two of its tags, and the link and the preview of its file Whenever the dashboard shows the widget
Nextcloud Paperless The saved searches of the users who asked for notifications, among the IDs of the new documents with files, and the API token Once per distinct search, when a new document has its file, and once per new search as a user saves it
Paperless Nextcloud The IDs and titles of the documents that it added since the last run, and the IDs of those that each search finds Every five minutes while someone asks for notifications
Nextcloud The browser or an app of the user The number of the new documents that the user asked for and can open, and of the newest three the title, the ID and the path of the file As the client fetches its notifications

The data flow of a search: A user searches for invoice. The unified search passes the term, the cursor, the limit, the date filter and the user to the search provider. Without a term, an archive account or a connection, the provider answers with no results and doesn't ask Paperless. Otherwise, until the page of results is full, the Paperless client asks Paperless-ngx with the token for the page of 25 hits that holds the next hit, within the days of the date filter, and only for the fields that a result shows, and Paperless answers with the ID, the title, the date, the IDs of the correspondent, the type and the tags and the excerpt of documents 412, 389, 371 and more, and whether a next page exists. One call of the file locator covers all documents of that page and returns for each a file of the archive account with its marker, or none. For the documents with a file, the names ask Paperless, through the client, for the correspondents, the types and the tags that the cache doesn't hold, with one request per kind, and keep their names for ten minutes. This repeats for at most 4 pages of Paperless, or 20 while it has found no result yet, or 3 seconds. The provider answers with an entry for every document with a file, up to the limit, with the preview of the file or the icon of its type, the title, the date in the language of the user, the correspondent, the type and the excerpt, and, when it found one result more than the page holds, the sealed cursor of that result, which it leaves for the next page.The data flow of a search: A user searches for invoice. The unified search passes the term, the cursor, the limit, the date filter and the user to the search provider. Without a term, an archive account or a connection, the provider answers with no results and doesn't ask Paperless. Otherwise, until the page of results is full, the Paperless client asks Paperless-ngx with the token for the page of 25 hits that holds the next hit, within the days of the date filter, and only for the fields that a result shows, and Paperless answers with the ID, the title, the date, the IDs of the correspondent, the type and the tags and the excerpt of documents 412, 389, 371 and more, and whether a next page exists. One call of the file locator covers all documents of that page and returns for each a file of the archive account with its marker, or none. For the documents with a file, the names ask Paperless, through the client, for the correspondents, the types and the tags that the cache doesn't hold, with one request per kind, and keep their names for ten minutes. This repeats for at most 4 pages of Paperless, or 20 while it has found no result yet, or 3 seconds. The provider answers with an entry for every document with a file, up to the limit, with the preview of the file or the icon of its type, the title, the date in the language of the user, the correspondent, the type and the excerpt, and, when it found one result more than the page holds, the sealed cursor of that result, which it leaves for the next page.

Nextcloud stores the settings in its app configuration, with the warnings about the account of the token that the last test found, the token encrypted in its credentials manager, and the history of the latest 20 problems, without the term, the token and the query of any URL. Its distributed cache keeps the names of correspondents, types and tags for ten minutes, and of the 25 newest documents their IDs, titles, the moments that Paperless added them and the IDs of their correspondents, types and tags for a minute, for all users; nothing of the text of the documents is stored. Architecture explains every step, and the security design what protects each of them.

Security and privacy

  • The Paperless API token is stored only in Nextcloud's server-side credentials manager.
  • The token is never returned to browser JavaScript or rendered into HTML.
  • The token is sent only to the Paperless server it was saved for; a URL with another scheme, host or port needs it entered again.
  • Saving the settings and disconnecting ask for the administrator's password when it wasn't confirmed in the last 30 minutes.
  • occ takes the token from its standard input or an environment variable, never from the command line, where the history of the shell and the list of processes would show it.
  • Nextcloud's protection against addresses of the local network stays on for every app. Paperless runs in my local network lifts it only for the requests of this app to the Paperless URL of the settings, which follow no redirect.
  • Search results are filtered through the current user's Nextcloud filesystem view.
  • A user whom Paperless Sync lets see only the documents with some tags meets only the documents whose tags in Paperless, as Paperless sends them with each document, hold one of theirs, everywhere the app shows a document; while Paperless doesn't list their tags, they meet none.
  • A file of the archive account stands for a document only for a user who may only read it: one that the user may change, or one in a folder of the archive account where the user may add files, could carry the marker of any document. The settings, occ paperless_unified_search:check and the overview warn about every share of the archive that allows changes.
  • The settings show administrators the history of the problems of the search without the API token, the search term or the query of any URL.
  • Try a search shows administrators which documents a user finds for a term, by their IDs, titles and tags alone, without their content, an excerpt or their files; the audit log of the app Auditing / Logging (admin_audit) records which administrator tried a search as which user, whatever the log level, and so does the log of Nextcloud at level info, without the term.
  • Search terms are sent server-to-server only when connected-services search or trusted-service mode is enabled, when the user chose Always search my Paperless documents in the personal settings, after the user chose Paperless documents in the smart picker, or when a client asks this search by its ID through the API.
  • A link that the smart picker inserts is the link of the file in Nextcloud, which shows its preview only to readers who can open the file.
  • The saved searches of the notifications about new documents stay with the account of the user who saved them, and a background job sends them to Paperless once documents with files are new, as the personal settings say above the field. A notification goes only to a user who can open the file, with its title.
  • The dashboard widget shows a user only the newest documents whose files they can open. Nextcloud's distributed cache keeps the IDs, titles, correspondents, types, tags and owners of up to the 100 newest documents for a minute, which are the same for every user, and of the 25 newest of a user of Paperless, and never their text.
  • Administrators can explicitly trust the configured Paperless server to include it automatically in every user's global searches.
  • No deployment credentials, private hostnames, internal addresses, or instance configuration belong in this repository.
  • Gitleaks scans the commits of every pull request, and every week the whole history.
  • Dependency Review blocks newly introduced vulnerable or unapproved dependencies.
  • Psalm analyzes the PHP code and CodeQL scans the JavaScript on every pull request.
  • Every release includes SBOMs as SPDX and CycloneDX, the THIRD_PARTY_NOTICES.md of its dependencies, a detached signature, and public Sigstore build provenance.
  • OpenSSF Scorecard audits the repository's supply-chain security every week.

See SECURITY.md for reporting security issues.

The log of Nextcloud

The app writes to the log of Nextcloud with app set to paperless_unified_search, never with the term or the token:

Level Message Means
Warning The test of the connection to Paperless failed: reason (error) Test connection and save failed; the reason is the code of the routes above
Error The settings of Paperless Unified Search could not be saved (error) Something after the test failed, such as the database
Warning The search account could not be set up in Paperless: reason (error) Create the search account and save failed; the reason is the code of the routes above, and the error is without the token of the superuser
Info admin created the search account account in Paperless Create the search account and save worked; the audit log records it too
Warning Paperless unified search failed (error) A search failed; Search problems has it too
Warning Paperless unified search left out n result(s) it could not show (error) Results whose files failed to answer were left out
Warning Paperless unified search skipped n file(s) it could not read (error) Files of the archive that Nextcloud couldn't read
Warning Paperless unified search looks for the files of each document on its own … A version of Nextcloud whose query of the file cache the app doesn't know yet: the search still works, with one query for each document instead of one for each page
Warning The stored Paperless API token can't be decrypted … The secret of config.php changed: enter the token again
Warning The notifications about new Paperless documents try again in n seconds (error) The job couldn't ask Paperless or look for the files, and rests
Warning n saved search(es) of the notifications about new Paperless documents failed (error), of the users users: they find nothing in this run Paperless answered the run but not these searches, such as a wildcard that took too long: they found nothing, and everybody else still gets their notifications
Warning A user got no notification about new Paperless documents (error) The files of that user failed to answer, or Nextcloud refused the notification; the others got theirs
Info Paperless refused n saved search(es) of the notifications about new documents, of the users users: they find nothing until the users correct them in their personal settings Those searches found nothing in this run, such as one saved before the personal settings checked a new search, or one that a newer Paperless reads differently; the log names the users whose searches they are, not the searches
Info Paperless added n or more documents between two runs of the notifications about new documents: older ones get none A large import
Debug Paperless rejected the query of a search with HTTP status A query still being typed, or a page past the last one: no problem

Uninstall

  1. Disconnect in the settings. It deletes the URL, the token, the switches, the archive account, the version of Paperless, the progress of the notifications about new documents and the history of the problems; only diagnostics_pending stays, with the keys that Nextcloud keeps of every app, such as enabled and installed_version.
  2. Remove the app: occ app:remove paperless_unified_search disables it and deletes its code; or Apps → Disable and Remove in the browser. Nextcloud keeps the app configuration of a removed app: occ config:list paperless_unified_search lists what is left, and occ config:app:delete paperless_unified_search <key> deletes a key. The choices of the users stay as their preferences always_search and new_document_alerts, the latter with their saved searches, which occ user:setting <user> paperless_unified_search always_search --delete and the same with new_document_alerts delete.
  3. In Paperless, delete the API token, or the account of the search: a token that Nextcloud forgot still works until Paperless forgets it too.

The files of the archive and their shares stay as they are: they belong to the archive account and to the synchronization, not to this app. Without Disconnect, the encrypted token stays in the credentials manager of Nextcloud, under paperless_unified_search.api-token, until the app is installed again and disconnected.